Arrrgh! Shadow volume problem... help please
http://i10.tinypic.com/4vs4sbq
Some of the shadow intersections, instead of forming a union, cancel each other... and I don't know why or how to handle it (floor is a white plane, light is directional from [10, 20, 10]).
It's Z-pass since no object is behind the viewer.
First pass:
// Draw dimly lit objects
Shadowing pass:
glPushAttrib(GL_ALL_ATTRIB_BITS);
glDisable(GL_LIGHTING);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE);
glShadeModel(GL_FLAT);
glDepthMask(GL_FALSE);
glDepthFunc(GL_LESS);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(0.0f, 2.0f);
glDisable(GL_CULL_FACE);
glActiveStencilFaceEXT(GL_FRONT);
glStencilFunc(GL_ALWAYS, 0, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR_WRAP_EXT);
glActiveStencilFaceEXT(GL_BACK);
glStencilFunc(GL_ALWAYS, 0, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR_WRAP_EXT);
glEnable(GL_STENCIL_TEST_TWO_SIDE_EXT);
// Draw extruded shadow volumes, no cap just 0.0 homogeneous coordinate
Last pass:
glEnable(GL_LIGHTING);
glStencilFunc(GL_EQUAL, 0, ~0);
glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP);
// Draw lit objects
Hello,
It's been a while since I've used the stencil functions, but try incrementing first and then decrementing. Then use GL_GEQUAL for the glStencilFunc when you're drawing. If it doesn't work, just experiment with incrementing/decrementing and all possible stencil functions. One of them should work.
Jeroen
It's been a while since I've used the stencil functions, but try incrementing first and then decrementing. Then use GL_GEQUAL for the glStencilFunc when you're drawing. If it doesn't work, just experiment with incrementing/decrementing and all possible stencil functions. One of them should work.
Jeroen
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement