I'm going to be writing a very simple renderer, mainly for learning purposes (using OpengGL). I've been wondering about how to implement support for dynamic number of light sources. Two solutions that come to my mind are:
Define an upper limit for each kid of light source (point, directional etc) and pass an array of lights in an uniform.
Write a shader for each of the light source type, iterate over each light in the scene and invoke it's appropriate shader, giving it as input the gBuffer with positions, normals and etc. This seems inefficient for me, as we will loop
ntimes through the fragments in the framebuffer, where
nis the number of lights.
Are there any more solutions?