Stencil Shadows + Per-Pixel Lighting,
Crossbones+ - Reputation: 2442
Posted 08 September 2012 - 05:36 AM
Crossbones+ - Reputation: 5893
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: 48948
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.