Depth Function to use in this situation

Started by
1 comment, last by MotionCoil 18 years, 9 months ago
Hey I just got blending sorted out in my editor which is fun and makes a pretty level. However, I am coming across a few problems- that being my depth function is culling polygons that should be seen through translucent polygons. Heres my example:

 ______
|      |
|  []  |
|______|

   ^
   |
 Front
Imagine that to be 2 3D cubes (but from the top). The little cube is dead in the centre of the bigger cube. Now, I have set it so the 'front' face of the big surrounding cube is translucent but the rest of the faces are infact totally solid. I want to be able to see the little cube through the translucent front face. At the moment my depthfunc is set to GL_LEQUAL however this just culls the little cube. If I set it to always...well you can just imagine how screwed my level looks after that. Is there a way around it like setting the depth func to something different if there is a translucent object, then setting it back again to LEQUAL. Or is there another way... Thanks in advance -Moco
Advertisement
the 'traditional' way of solving this problem is to render all semi-transparent surfaces AFTER all the soild one in order from back to front, with depth testing on but depth writes off.

So, in this instance you'd draw your cubes, missing out the transparent front face and then do a transparent pass where you draw the front face in.
Cheers, I never knew that. Guess these are things you pick up on the way.

I'll give that a try, it'll be easy to implement in my world view [smile]

This topic is closed to new replies.

Advertisement