PDA

View Full Version : Question about managing lights in a basic light system.



Alberto García
07-18-2017, 01:00 PM
Hi guys, I have implemented differents lights by GLSL, ( points, spot, directional ). Now I want to program a basic lights system, which only manages static lights and uses forward rendering.

I have read that for example engines like Doom 3 use only 8 light sources in the shader, but then my question is: are 8 light sources per rendered mesh, or are 8 ones for the whole scene.

In the first case, I need to get the eight lights that have more influence for each mesh that will be rendered.
In the second one, I need to get the eight lights that have more influence in the entire scene that will be rendered.

Thanks in adavance.

mhagain
07-18-2017, 02:02 PM
Doom 3 can support an arbitrary number of lights, although in practice the number of simultaneous lights per fragment is limited, but this is for performance reasons rather than on account of any kind of limit.

Fortunately the source code is available (https://github.com/id-Software/DOOM-3) so you can study it and learn how it worked. And so that we can avoid debates containing erroneous claims about how it worked. :)

In summary, and simplified a little, Doom 3 first fills the scene to black, then enables additive blending and accumulates each light individually, with shadowed out regions excluded using the stencil buffer.

Accumulating each light individually is important, there is no loop over a number of lights in it's shaders, instead each pass just handles one light, but there can be any arbitrary number of such additive passes, with no upper limit.