Transparency in Depth Buffer
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
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"]
[edit: changed "less than" to "greater than"]
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement