Sign in to follow this  

Transparency in Depth Buffer

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

This topic is 3374 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this