//See if the light volume contains eye point and set appropriate culling state
if(contains(volume,eye))
glCullFace(GL_FRONT);
else
glCullFace(GL_BACK);
Stencil Test Algorithm
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.
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
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
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
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement