Arrrgh! Shadow volume problem... help please

Started by
1 comment, last by godmodder 16 years, 8 months ago
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
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)
Advertisement
Anyone? I still haven't figured it out...
"But who prays for Satan? Who, in eighteen centuries, has had the common humanity to pray for the one sinner that needed it most?" --Mark Twain

~~~~~~~~~~~~~~~Looking for a high-performance, easy to use, and lightweight math library? http://www.cmldev.net/ (note: I'm not associated with that project; just a user)
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

This topic is closed to new replies.

Advertisement