Masking (and the order of rendering objects)

I have a problem with masking & depth, if I draw masked triangles/quads behind each and don’t draw them in de right order the masked objects aren’t visible.

I have tried the code from the NEHE masking tutorial and code loading a image to a texture with an alpha channel.

This is how it’s supposed to look

This is what happens if the

As you can see the front object isn’t transparent anymore…

What I have tried is enabling / disabling the following options:


I’ve already found a kind of a solution and that is writing a custom depth testing function, I don’t think that’s the best solution… has anyone got a better way of solving this problem??

In fact, apart from additive transparency, (almost) all blending modes are order dependant. There are a lot of people trying hard to do “order-independent transparency” (just Google for it) but it is often slow and complex.

So you do have to pre-sort your transparent faces, and draw them back to front, after drawing all opaque geometry.

In this case, you may be able to get away with alpha test.


Alpha test, unlike blending, produces hard transitions aka aliasing, and it defeats multisampling (which is now the preferred way to reduce aliasing).

An edge that is alpha tested and blended may or may not block what is rendered behind it, depending on rendering order. If you don’t like that, you can turn off blending (this will further sharpen the edges though).

[This message has been edited by zeckensack (edited 02-27-2004).]

Yes!! that works thanx alot guys !!