Question about managing lights in a basic light system.

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.

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 so you can study it and learn how it worked. And so that we can avoid debates containing erroneous claims about how it worked. :slight_smile:

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.