DirectX and alpha z-ordering

Blitz3D Forums/Blitz3D Programming/DirectX and alpha z-ordering

JoshK(Posted 2004) [#1]
I heard there was a setting in DirectX that automatically z-orders triangles, and that it was just a matter of activating a "flag", kind of like glEnable(). Is this true?


Gabriel(Posted 2004) [#2]
I think Mark said that it was not desirable to do this because Z-sorting everything would make things very slow. It would be nice to be able to set a flag to activate z-sorting, but it's been requested dozens of times already, so we're probably not going to get it.


JoshK(Posted 2004) [#3]
Right, so you only activate it on brushes that are alpha-blended. Or just add another BrushFX flag for z-ordering. It's much faster to let the card handle it, than to go through and write a sorting algorithm in software.

Is there a reason this hasn't been done?


AntonyWells(Posted 2004) [#4]
I think mark wants to save all things we wanted for the new engine.


Beaker(Posted 2004) [#5]
My Alfa Zorder in the code archives is a fairly handy compromise.


Damien Sturdy(Posted 2004) [#6]
i think that alpha bug were getting is making a feature of blitz broken and therefore it should be fixed at some point :/


JoshK(Posted 2004) [#7]
Beaker, any routine you write will be slower than letting the gfx card handle it.


AdrianT(Posted 2004) [#8]
I'd love something that z sorts alpha brushes with a flag. the alpha sorting issues in blitz has manifested itself in just about every engine I have worked in, but never quite so terribly, and a work around was allways found. the last one culled all the alpha polys you couldn't see and only sorted visible alpha polys. Seemed to work prety well.

If it were possible to add it as a texture flag it seems silly to leave it out. give people the choice then I don'r see the problem.


Shambler(Posted 2004) [#9]
I've just searched through the DX9 docs and there's nothing in there to do this in hardware yet.

[Edit] In their billboard sample which uses sprites to display some alpha blended trees they sort the trees in C++ software only, not hardware...

//-----------------------------------------------------------------------------
// Name: TreeSortCB()
// Desc: Callback function for sorting trees in back-to-front order
//-----------------------------------------------------------------------------
int __cdecl TreeSortCB( const VOID* arg1, const VOID* arg2 )
{
    Tree* p1 = (Tree*)arg1;
    Tree* p2 = (Tree*)arg2;
    
    FLOAT d1 = p1->vPos.x * g_vDir.x + p1->vPos.z * g_vDir.z;
    FLOAT d2 = p2->vPos.x * g_vDir.x + p2->vPos.z * g_vDir.z;
    if (d1 < d2)
        return +1;

    return -1;
}