Question regarding shaders and shadow volumes

Hey guys,

I have a question regarding shadowing and shaders.

I have an application which renders streetlamps and projects a spotlight into the scene onto my flat plane ground and onto the sides of houses.

To do this I first of all filter out which polygons are visible to each streetlamp in its spotlights’ immediate area of influencem then I pass those polygons to my cg shader which does the spotlight calculations. Now, because i dont yet have shadowing the ground is also lit underneath the house which of course shouldn’t be happening.

I want to implement shadows and have had some problem with shadow mapping already, and also because I already have sorted out the polygons visible to the light, I thought I should try shadow volumes as I can simply extrude out past the polygons visible to the light.

However one part of the problem is confusing me and I want to clarify it before i start coding it.

If i set up the shadow volume, how will my cg shader be able to perform the relevant stencil tests? i’m sorry if the question is a little vague but i’m really confused on how I’ll do the actual testing against the stencil buffer in my shader.

Can anyone assist me please?

Thanks

The stencil test wouldn’t be done in a shader. The stencil will be executed before the shader runs (early out)