Optimize Multiple Dynamic Lights in Three.js

Rendering multiple dynamic lights in Three.js can drastically reduce frame rates due to increased draw calls, complex shader calculations, and shadow map overhead. This article outlines key strategies to optimize your render performance when your 3D scene requires multiple dynamic light sources, focusing on light culling, shadow optimization, material selection, and alternative rendering pipelines.

Limit the Range and Culled Lights

By default, Three.js calculates the influence of active lights on all materials within the scene graph. To prevent unnecessary calculations, you should actively manage which lights are enabled based on their proximity to the camera.

Optimize Shadow Maps

Shadows are the most performance-intensive aspect of dynamic lighting because each shadow-casting light requires rendering the scene from its own perspective into a depth texture.

Use Cheaper Materials

The complexity of your materials determines how expensive the lighting calculations will be in the fragment shader.

Leverage WebGL 2 and Clustered Forward Rendering

Standard Three.js forward rendering calculates lighting for every light source on every single fragment, which scales poorly.