i’m feeling a bit stupid… i have z-fail shadow volumes which are working fine aside from the well-known glitches with self-shadowing on spheres etc. so i’d like to add an option which disables self-shadowing. i thought i could do so simply by rendering the extruded silhouettes as usual and then render the mesh itself in the stencil buffer… but with which stencil op/func do i have to render the mesh?!
[li]Render shadow volumes for everything except for objects that should be not self-shadowed.[]Render the objects that should be not self-shadowed with lighting from that light.[]Without clearing the stencil render shadow volumes for the objects that were skipped in first step.[*]Render rest of the lit geometry.
Obviously the problem is that objects that are not self-shadowed will not cast shadows on other such objects. I think that this is what Doom 3 does, if I correctly understand talk made by Carmack on one Quakecon.
The anti self-shadowing render needs to be done using glDepthFunc( GL_LEQUAL ). Otherwise the depth test fails because the object geometry is already contained within the depth buffer with the same depth values.
One additional note. The glStencilOp( GL_KEEP, GL_KEEP, GL_ZERO ) render will erase all shadows on corresponding object that are casted by objects whose shadow volumes were rendered before so you might wish to introduce some ordering into the rendering of shadow volumes.
The anti self-shadowing render needs to be done using glDepthFunc( GL_LEQUAL )
why have i been switching the depth function at all? Oo removed those switched and set GL_LEQUAL in the ctr, still does not help… thanks anyway
Originally posted by Vexator: why have i been switching the depth function at all? Oo removed those switched and set GL_LEQUAL in the ctr, still does not help… thanks anyway
What is the result after the change? Is the self-shadowing visible, it is the same as on the image you post or something different is wrong?
You can use the GLIntercept to see changes made to depth and stencil buffers by individual OGL calls. This might give you a clue what does not work as expected.