How do I stop light entirely from leaking inside meshes from directional light3d? (full darkness)

Godot Version

4.2

Question

I’m trying to make a 3d game with lighting in a large scene. Most of the scene is a desert with a rising and setting sun. However there are some caves in the scene that I would like to be completely dark. These caves are under a mountain and I’m not sure why the mountain is not blocking the light from the directional light. You can still see fully in the interior of the caves as well as light coming in from the rising sun.

I’ve tried researching so many things but none of them work. What’s the best way to get dark interiors in a directionally lit scene?

First check the shadow distance for your directional light. It should be much greater than the size of your cave interior.

Beyond that you may have light bleeding though your mesh for various reasons such as faces that are too big. The most direct approach to solving this is to have an extra hidden wall behind your cave walls. You can set a mesh to cast shadows only just for this.

If you want it to be completely dark in the cave then you are also going to have to write a script to transition the ambient lighting in the scene to black when entering the cave and back to light blue or what ever when exiting. You could also just turn off the sun completely when deep inside the cave.

I was thinking about that for the sun and considering that as a last resort option. I figured there must be a better approach that involved a common solution.

I would think a multiplayer game that had dark caves…must work differently?

Why should it be different? Each computer manages the lighting based on where its player is located.

Wow. I wonder if games do it that way. Thanks for the info!