Depth Sort

sorenknud's picture

Hi there - to keep the text short:

Should i just forget all about getting this to work: The attached file.

(the problem is that there is always one sprite thats NOT transparent.)

from my reading at: http://www.opengl.org/wiki/Transparency_Sorting - it seems that it is impossible to make the example i attached work.

Is this really true???

best,

soren

PreviewAttachmentSize
depth sort.qtz506.02 KB

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cwright's picture
Re: Depth Sort

To get this to work generally, you need the ability to split polygons at their intersections. OpenGL doesn't do this for you, and probably never will. Doing so requires intersection-testing every poly in a scene with every other poly, which takes exponentially more time as more polygons are added (in CompSci, this is referred to as "O(N^2)", which is pretty bad).

QC is abstracted on top of GL. It has no provisions for splitting polys, and further, has no provisions for depth-sorting geometry anyway - it uses layer order to drive rendering, which make even non-overlapping cases problematic (for example, a transparent layer 1 sprite will prevent a layer 2 sprite positioned behind it from rendering "through" the first layer).

One way to solve the case you provided (outside of QC) is to have 4 sprites instead of 2 -- each "wing" becomes its own sprite, all joined at the center. QC's layer ordering will still make this not work as you're intending though.

[tl;dr version: yes, it's true]

smokris's picture
Re: Depth Sort

Yep, you're encountering the mutually-overlapping-geometry issue. As recommended in the article you referenced, try splitting the sprites. Instead of using two sprites, try subdividing into four sprites --- four spokes emanating from the origin. Depth Sort Environment should then be able to handle this properly.

sorenknud's picture
Re: Depth Sort

Thank you both, it really helped me out.

best, soren