Change Eevee's MAX_LIGHT in a custom build

The file source/blender/draw/engines/eevee/eevee_private.h lists macro substitutions that match Eevee’s limitations (in particular, the MAX_LIGHT macro sets the maximum allowed number of light sources, which is 128 now).

I would like to make a custom Blender build with the MAX_LIGHT value increased to 2048. But changing the value directly only works when rendering is done on CPU. When using GPU, Blender crashes. How can I correctly raise this limit so that the build will work when rendering on GPU as well?

In the same file where this macro is defined there is a TODO task for calculation of MAX_LIGHT with respect to UBO max size (find size by dividing UBO max size by light data size). Could anyone please guide me how and where to change the UBO size correctly? Maybe I can make the patch needed for TODO and at the same time figure out how to raise the limitation value I need in a custom build. (In this case, it doesn’t matter to me that the viewport might become unresponsive.)

What the comment means is that GPU hardware has a maximum UBO size. This can’t be increased, what the comment suggest is to set the max number of lights based on hardware limitations. 128 is a conservative guess that might be too low, 2048 may exceed what your GPU can do.

3 Likes