Problem with z-fighting on shadow volumes

I’m implementing the shadow volume solution from the NVidia SIGGRAPH 2002 Robust Shadow Volumes paper, but I’ve ran into some problems. The shadow volume is stable, and the region that is supposed to be shadowed is perfectly defined, but I’m getting some z-fighting on the near capping of the shadow volume (the one where you simply draw the faces visible to the light source), which is screwing up the scene.

I checked it several times, but I couldn’t find anything wrong, so I think the problem might be caused because I render the actual object from a vertex buffer, but the shadow volume through immediate mode calls… Has anyone ran into a similar problem? Any ideas?

Thanks already!

I also ran into this problem. The only solution i could find was to use
which unfortunately is supported only by nvidia.
Hopefully Ati will include such an extension too…

Everything you ever wanted to know about stencil shadows, including the solutions to all of your problems, can be found on Gamasutra in this article:

A slightly updated version of this article also appears in the just-released second edition of Mathematics for 3D Game Programming and Computer Graphics: