So far in my game engine I’ve been keeping things simple, with a single directional light (sunlight). However, it would be nice to have point lights for local light sources - candles, lamps, fireplaces and so on, as well as dynamic lights for spells. This is particularly important if I plan to add day/night cycles into the game.
Up to this point, though, I’ve been hesitant to introduce anything like this because I don’t know what effect it would have on overall frame rate, and that’s partly because I really don’t understand how lighting works in three.js.
Static lights - such as candles - would generally have a small radius of influence and would not overlap with other point lights (in fact I could enforce this in the level editor). This would mean that even though a scene might have dozens of individual light sources, individual shader fragments would have at most two lights: the directional sunlight and the nearest point light.
Note that when I talk about a “scene” I’m talking about something that is very dynamic: the game engine supports worlds of effectively unlimited size, with scenery loaded asynchronously in the background as you travel across the terrain. This would mean, then, that the number of lights in the scene is constantly changing.
For things like spells, I can’t guarantee that the radius of effect would never overlap with other lights, but since the game’s combat is quasi-turn-based, only one spell is cast at a time. So that means that there would be three lights per fragment at most.
Then there is the question of shadows. I imagine that rendering a shadow map for dozens of individual point lights would be horribly slow. I supposed point lights could have shadows turned off, although that would not be as nice looking.
So what I’m asking is, before I start doing a bunch of work to integrate point-lighting into the engine, can someone give me a sense of whether this is even feasible, or will it have such a huge negative impact on framerate that it’s not worth pursuing?