Original Post
Hello everyone! I'm trying to render a scene with 2 cubes and a light source. I'm using the stencil buffer to create shadow volumes... The light is above the 2 cubes and each cube creates a shadow. The problem is that when the 2 shadows fall on the same piece of surface, the scene looks like I have no shadow there: http://geocities.com/gsmcreation/untitled.GIF Could anyone tell me what I'm doing wrong in this code? glClear(GL_DEPTH_BUFFER_BIT | GL_COLOR_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); glClearStencil(0); glDisable(GL_LIGHT0); drawScene(); glEnable(GL_STENCIL_TEST); glDepthMask(GL_FALSE); glStencilFunc(GL_ALWAYS, 1, 0xffffffff); glStencilOp(GL_KEEP, GL_KEEP, GL_DECR); glCullFace(GL_BACK); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // draw the shadow volumes pass 1 makeShadowVolume(objects[1], light_position0, 15.f,0); makeShadowVolume(objects[0], light_position0, 15.f,0); glStencilOp(GL_KEEP, GL_KEEP, GL_INCR); glCullFace(GL_FRONT); glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // draw the shadow volumes pass 2: makeShadowVolume(objects[1], light_position0, 15.f,0); makeShadowVolume(objects[0], light_position0, 15.f,0); glDepthMask(GL_TRUE); glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); glCullFace(GL_BACK); glDepthFunc(GL_LEQUAL); glStencilOp(GL_KEEP, GL_KEEP, GL_KEEP); // HERE MAY BE THE PROBLEM: glStencilFunc( GL_GEQUAL, 0, 1); glEnable(GL_LIGHT0); drawScene(); glDisable(GL_STENCIL_TEST); glDepthMask(GL_TRUE); glDepthFunc(GL_LESS); Thank you.