How to have multiple directional lights with shadows that all work together in a 3D scene ?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yvan

In a 3D scene, I tried to put 2 directional lights with the shadows activated.

Each works well separately (i see the shadows), but as soon as both are visible, only the shadows of the first directional light in the scene tree are visible.

Is this normal ?

PS I did not find in the documentation (maybe I searched wrong…) anything indicating that the number of directional lights was limited.

For reference, this was cross-posted on the Godot forums: https://godotforums.org/discussion/29906/multiple-directional-lights-in-3d

Calinou | 2022-05-21 23:15

:bust_in_silhouette: Reply From: Calinou

Cross-posting my answer from Godot forums for posterity:

Godot 3.x only supports one DirectionalLight with shadows at a time.

In Godot 4.0, using more than 1 DirectionalLight will always have a significant performance impact, especially if shadows are enabled on more than 1 DirectionalLight. Doing so will also worsen shadow quality, as the shadow map texture will have to be shared for multiple DirectionalLights.

As a conclusion, in Godot 4.0, even if it doesn’t look physically accurate for your game, I strongly recommend sticking to 1 DirectionalLight for best performance and quality.

PS: OmniLights with shadows are not intended to be used as a replacement for DirectionalLights. You could increase the shadow atlas size (or use a distant SpotLight instead), but it will never look ideal since there is only one shadow “split” to speak of.