Transparency Problems

I’m using glDepthMask(GL_DISABLE) with alpha channels enabled to make objects with an alpha channel less than 1.0 look semi-transparent. But when I enable it, all the objects I’ve drawn are then displayed in the exact reverse order than they were originally drawn. (meaning, instead of displaying the first drawn object front-most, it’s display the last drawn object front-most) Is it supposed to do that? Is there a better way of doing what I want, or am I a moron? :slight_smile:

I’m assuming you have a non-symmetric blend function.

If you think about your blend function, you’re basically taking the background and mixing it in with the fragments you’re rendering.

As such, the first thing you draw will effectively blend properly with the background. But subsequent overlapping objects will consider the current blended image as the new background, and blend on that.

So in effect, the first object you blended looks like it’s the one that should be furthest away.

So when blending, you really want to draw the furthest object first, followed by the next-furthest object, etc, with the front-most object drawn last.