Jump to content
  • Advertisement
Sign in to follow this  
AverageJoeSSU

Stencil Test Algorithm

This topic is 3901 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 Guys, I am trying to implement deferred shading, and i am getting close, however there are a couple things still left to implement. I have the code written for implementing the Stencil Test Algorithm, but there is a line of code in the example that isnt really explained.

//See if the light volume contains eye point and set appropriate culling state
if(contains(volume,eye))
 glCullFace(GL_FRONT);
else
 glCullFace(GL_BACK);



If someone could explain what is going on in this code... i mean...you are seeing if the eye position lies within the mesh of the light volume correct? but what does setting the cull face have to do with it? -Joe EDIT: typo

Share this post


Link to post
Share on other sites
Advertisement
I assume the code following the snippet you posted renders the light volume into stencil in order to mark which pixels are affected by the light, correct?

When the camera's near plane intersects the light's volume (in your example the author test this with just the position of the camera), culling back faces will not alter the stencil buffer. Imagine being inside a cube with its faces facing outwards, with back-face culling enabled. Are you going to see anything? No. That's why he alters the cull face, in order to cull front faces instead of back faces, and get the desire result (something to be drawn in the stencil buffer).

Hope that helps (and i haven't said anything wrong). Forgive my english.

HellRaiZer

Share this post


Link to post
Share on other sites
yes that makes sense. If the camera is in the light volume... you do not want to light the outside of the light volume.. you want the inside of it.

Thanks for the help.

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!