View Full Version : Shadow Volumes multiple lights?

01-03-2017, 09:44 AM
Shadow Volumes multiple lights? Is this possible?

Any tutorials, examples?
i need it using glsl because I'm clipping my scene with glsl discard funtion and don't want to produce shadows when doing this.

Any ideas? Or other implementation other than Shadow Volumes that can have multiple lights, and cast shadows off every wall or object?

This is really getting to me.

01-03-2017, 01:11 PM
This is what the game Doom 3 (https://en.wikipedia.org/wiki/Doom_3) did, so that's a working example that proves it's possible. The Doom 3 source code is open source and available on Github at https://github.com/id-Software/DOOM-3, but be aware that it uses older assembly shaders rather than GLSL. A more recent refresh of the code is also available at https://github.com/id-Software/DOOM-3-BFG that does use GLSL.

The basic algorithm is:

- Clear the scene to black.
- Do a depth-only pre-pass of all objects.
- Enable additive blending (glBlendFunc (GL_ONE, GL_ONE)).
- For each light:
- Figure which objects are in the light's radius.
- Draw shadow volumes to stencil buffer.
- Draw lit objects.

So in other words it's a multi-pass algorithm, with each light being an extra pass. If that sounds like excessive overhead, remember that a 2004 game did it on 2004 hardware.