Jump to content
  • Advertisement
Sign in to follow this  
Geometrian

Transparency in Depth Buffer

This topic is 3592 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

Hello, I'm anticipating trouble in my program--I recently succeeded in making a shadow-mapping algorithm, and am now using it to finish a few games. Some of my models are quite complex. To save time, effort, and speed, I used textures using transparency to add detail. The opacity is either 0% or 100% for a given pixel. I'm betting, however, that the transparent pixels will still be rendered into the depth buffer, and cause strange-looking shadows. I need some way to make only completely opaque pixels be read into the depth buffer. Ideas? Thanks, Geometrian

Share this post


Link to post
Share on other sites
Advertisement
During the shadow rendering pass (i.e., the depth render pass), be sure to write alpha in your pixel shader (i.e., sample your texture and output the alpha). Enable alpha-testing (one of the glEnable states) with the proper alpha compare function (probably greater than or greater than or equal) with the proper alpha ref/threshold. Pixels that get written that fail the alpha test (are less than your alpha ref) will be discarded prior to writing their depth, resulting in proper shadowing.

[edit: changed "less than" to "greater than"]

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!