Fast lighting with multple lights
- by codymanix
How can I implement fast lighting with multiple lights?
I don't want to restrain the player, he can place an unlimited number and possibly overlapping (point) lights into the level.
The problem is that shaders which contain dynamic loops which would be necessary to calculate the lighting tend to be very slow.
I had the idea that if it could be possible at compiletime to compile a shader n times where n is the number of lights. If the number n is known at compiletime, the loops can be unrolled automatically. Is this possible to generate n versions of the same shader with just a different number of lights?
At runtime I could then decide which shader to use for which part of the level.