Spot light with shadow volumes

Originally posted by greg2:
Tom Nuydens, do you think about using the texture projection method at 100% for spot light, or do you think about using a mix between shadow volumes and texture projection.
The problem of texture projection is that i would have to separate the shadow caster and receiver and there’s also the problem of aliasing.

I wasn’t talking about shadowing at all. The reason you would use a projected texture is so that no light would fall outside of the spotlight cone. This is a completely separate problem from shadowing, which you should still do using stenciled shadow volumes.

You’re thinking of rendering shadow casters into the texture. That’s not what I meant – the texture is simply a white blob on a black background, like so: http://www.delphi3d.net/misc/images/spot.gif

If you render using a normal omni-directional point light, and then modulate that with the projected texture, you’ll have all the light that your spotlight contributes to the scene, except that the light will pass through objects instead of casting a shadow.

With this in mind, the algorithm is now exactly the same as for omni lights:

Render Z-buffer and ambient light;
For each light:

  1. Clear stencil and render shadow volumes;
  2. Render light to unshadowed regions using additive blending;

The only difference between omni and spot lights is that in step two, you multiply the light contribution with the color from the projected texture.

– Tom

The issue of closed model vs open model plagues shadowing (shadow mapping is really the only thing that handles this elegantly). You MUST have topologically consistent models to use most forms of accelerated stencil-shadow rendering (gpu accelerated, etc.).

Self shadowing should work better for addative blending (you don’t have to worry about z-fighting issues as much). Go with the addative blending Tom and others have described, with the projective texturing if you’re using spot lights.

There are many demos (Tom’s are good…), papers (gamedev.net is pretty good), and books (Real Time Rendering is awesome) that describe lighting and what shadowing is trying to simulate. I’d suggest reading those, since they will probably help clear somethings up (why addative blending works so much better, etc.).

OK, so it’s pretty clear that you want to render fewer times, to render the scene faster, and you’ve already made the trade-off to use the fundamentally broken “darkening quad” mechanism.

I’m sorry, I don’t know how to make that work better for spot lights. Because it’s already fundamentally broken, I don’t know of anyone who is spending any time on actually researching it.

My, that’s a confusing thread.
So, the problem is that greg2 can’t apply a darkening quad that will have effect everywhere outside the spotlight’s cone…?

The obvious solution is to actually add light in the shadowing pass and modulate with a spotlight texture or use GL vertex spotlights. What jwatte has been saying from the start. That will definitely look best but of course requires an additional pass of the lit geometry.

But, greg2 doesn’t seem particularly keen on the soft spotlight effect and will be content with a hard projector (ala stencil shadow). In this case, he can use the darkening quad, and the solution is overly simple:

-Clear the stencil buffer to 1
-Draw spotlight volume inverting face winding (“antishadow”)
-Draw other shadow volumes normally
-Render quad where stencil > 1 (as usual)

Et voila’. Wasn’t that easy?

Ok.
I will take the time to think about all that.
Thanks.