Stencil Shadows + Per-Pixel Lighting
Members - Reputation: 681
Posted 08 September 2012 - 05:36 AM
Members - Reputation: 1987
Posted 08 September 2012 - 05:59 AM
As for constructing the actual shadow volume to create the mask, that can done with the geometry shader for example.
Moderators - Reputation: 13574
Posted 08 September 2012 - 06:10 AM
Render scene with ambient lighting only.
Generate stencil mask using a stencil-shadow-volumes technique.
Render scene with diffuse/specular lighting (which will only show up in the masked area).
However, to avoid the two-pass lighting, my personal approach would be to render the shadow mask into a full-screen texture as is done with "deferred shadows" (here, here, here). Your lighting shaders can then be one-pass, and fetch the value from that full-screen texture do determine if they are in light or shadow. Furthermore, you can switch seamlessly between stencil volumes or shadow-mapping, or both, when generating the full-screen mask.