Jump to content
  • Advertisement
Sign in to follow this  
Sir Sapo

Depth Buffer Problem

This topic is 4491 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!