Hi I have created my shadow volume and am having trouble getting my shadows out correctly.
I have checked that all my normals are correct on the shadow volume so I do not think that is the problem. Here are some images demonstrating the issue:
Here it looks fine
Here when I move the camera it screws up
I do not understand why it is not working, I am trying the Zpass method and have capped my shadow volume from where the object is. Everything from the objects to the lights are in world space.
These are the calls I am using:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT); // Clear the Screen the Depth Buffer and the Stencil Buffer
glLoadIdentity();
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LEQUAL);
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDepthMask(GL_TRUE);
RenderUnlitScene(); // with ambient only
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 0x0, 0xffff);
glEnable(GL_DEPTH_TEST);
glDepthFunc(GL_LESS);
glColorMask(GL_FALSE,GL_FALSE,GL_FALSE,GL_FALSE);
glDepthMask(GL_FALSE);
glEnable(GL_CULL_FACE);
for each contour edge
{
glCullFace(GL_BACK);
glStencilOp(GL_KEEP, GL_KEEP, GL_INCR);
BuildBackfaceShadowPolygon();
glCullFace(GL_FRONT);
glStencilOp(GL_KEEP, GL_KEEP, GL_DECR);
BuildBackfaceShadowPolygon();
glCullFace(GL_BACK);
}
glColorMask(GL_TRUE,GL_TRUE,GL_TRUE,GL_TRUE);
glDepthFunc(GL_LEQUAL);
glStencilFunc(GL_EQUAL,0,~0);
glStencilOp(GL_KEEP,GL_KEEP,GL_KEEP);
glDepthMask(GL_TRUE);
RenderScene(); // with lighting
So when I render my shadow volumes with normals they are all facing outward, but this thing just doesnt want to work. Anything I am doing wrong with the opengl calls??
If you cannot see those images: