Depth Buffer Problem

Started by
2 comments, last by Sir Sapo 17 years, 9 months ago
Hey everyone, Until recently, I was able to get away with rendering my objects in order from back to front, without using the depth buffer (its a 2D game). Now, however, I would like to use the depthbuffer so I don't have to order my draw functions, but I've run into a little problem. Whenever I enable depthtesting, the objects are drawn in the right order, but they get this wierd box around them that blocks out objects that are rendered behind them. I'm not sure why this is happening, so I was hoping that perhaps one of you guys could enlighten me. Here's a screenshot of the wierd effect: Thanks in advance
My Current Project Angels 22 (4E5)
Advertisement
It looks like you're still writing to the depth buffer even for transparent pixels, look up 'alpha test' or 'alphareftest', basically you can set a alpha value for pixels which then get discarded if they match the compare operation and so are not writtern into the depth buffer.

That should help you on your way (poor description I know but it's Friday night :) ),

Paul
It looks like you may need to enable alpha testing. I'm guessing that your sprites are alpha-blended, but that doesn't prevent the entire quad from being written to the depth buffer. Enabling alpha testing with the GL_GREATER function and a reference of 0 should do the trick, I would think. I could be overlooking something though.
Damn, I can't believe I forgot that, thanks guys, rate++ for the quick replys!
My Current Project Angels 22 (4E5)

This topic is closed to new replies.

Advertisement