Problem with shadow volume rendering

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:

http://imagestore.ugbox.net/image/d8b98074…e9cc2f1a2f3.jpg

http://imagestore.ugbox.net/image/2e46a66f…360dae31aa2.jpg

First of all your links don’t work at all.

Now, I’ve never done any shadow volumes yet, but I’m sure the Zfail algorithm is what you need. Try it.

You need to actually copy+paste it into the browser. Sometimes I need to press enter once or twice for the images to show up… but they are there :slight_smile:

Here’s what I have:

You’ve linked to…

Unfortunately your domain isn’t in the allowed list…