Performance when handling large number of lights in a city game

Hey @jhm.ciberman,

there are alternatives, as always. I ran into a similar problem in the past, as @Mugen87 stated - you can’t have more than a handful of lights in a standard forward rendering (which is how WebGLRenderer works), it would say 3 is already a stretch, as each light adds fragment shader overhead for each material as well as each light being added or removed causes all shaders to be re-compiled. It’s a bad idea all around.

Deferred rendering in three.js is pretty bad. What can one do? Well,

  • you can be okay with the deferred renderer in three.js
  • you can write your own renderer or switch to a different library that supports deferred rendering
  • you can fake lighting with lightmaps (as @Mugen87 suggested)
  • you can fake lighting with geometry and sprites. Things like light-beams and shiny glares create a good illusion of light

I use a mix of last two in my game to pretty good effect.

good luck

4 Likes