# Why does additional light disable shadows sometimes?

**URL:** <https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668>\
**Category:** Questions\
**Tags:** lighting\
**Created:** [September 26, 2025, 1:07pm UTC](https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668 "2025-09-26T13:07:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joe\_Kerr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joe_kerr/32/39017_2.png) [@Joe\_Kerr](https://forum.babylonjs.com/u/Joe_Kerr)\
**Post date:** [September 26, 2025, 1:07pm UTC](https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668/1 "2025-09-26T13:07:48Z")

</div>

Hi everyone,

Please have a look at this playground: [https://playground.babylonjs.com/#WLDCUC#253](https://playground.babylonjs.com/#WLDCUC#253)

Dude and Elf are missing shadows. But when I move the setup function of the clustered lights down, the shadows render. Why is that?

Best wishes  
Joe

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [September 26, 2025, 1:54pm UTC](https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668/2 "2025-09-26T13:54:56Z")

</div>

Assigned @Evgeni\_Popov on September 26, 2025, 1:54pm UTC



---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [September 26, 2025, 3:09pm UTC](https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668/3 "2025-09-26T15:09:56Z")

</div>

By default, materials are only illuminated by a maximum of 4 lights. When you call `addExtraLights` before `lightSetup`, 5 lights are created in the scene.

When `staticLight.includedOnlyMeshes` is updated with the dude/elf meshes, as part of the operation, all meshes in the scene are looped through and their internal `_lightSources` are synchronized with this light. Since the background plane is not yet in `staticLight.includedOnlyMeshes`, the light is removed from `backgroundPlane._lightSources`. When `backgroundPlane` is later added to `staticLight.includedOnlyMeshes`, it becomes the 5th light in `backgroundPlane._lightSources` (because the light is added at the end of the array), which means it does not contribute to lighting the mesh.

The solution is either to exclude `backgroundPlane` from one or more of the other 4 lights, or to update `material.maxSimultaneousLights` to 5 for this mesh. This is what I did in this PG (line 54):

> **[Babylon.js Playground](https://playground.babylonjs.com/#WLDCUC%23257)**
>
> Babylon.js playground is a live editor for Babylon.js WebGL and WebGPU 3D scenes

---

<div class="post-metadata">

**Author:** ![Evgeni\_Popov](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/evgeni_popov/32/4432_2.png) [@Evgeni\_Popov](https://forum.babylonjs.com/u/Evgeni_Popov)\
**Post date:** [September 26, 2025, 3:10pm UTC](https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668/4 "2025-09-26T15:10:08Z")

</div>

Unassigned @Evgeni\_Popov on September 26, 2025, 3:10pm UTC



---

<div class="post-metadata">

**Author:** ![Joe\_Kerr](https://sea2.discourse-cdn.com/flex024/user_avatar/forum.babylonjs.com/joe_kerr/32/39017_2.png) [@Joe\_Kerr](https://forum.babylonjs.com/u/Joe_Kerr)\
**Post date:** [September 26, 2025, 7:35pm UTC](https://forum.babylonjs.com/t/why-does-additional-light-disable-shadows-sometimes/60668/5 "2025-09-26T19:35:44Z")

</div>

Just to clarify: in my initial post, I thought ClusteredLightContainer was responsible. This was misleading. You can replace it with a PointLight for instance and get the same behaviour [https://playground.babylonjs.com/#WLDCUC#265](https://playground.babylonjs.com/#WLDCUC#265)
