How do I stop Directional Light from penetrating the mesh?

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

Hi All!

I want my (flying) character to fly into a tunnel and out the other end. Inside the tunnel I want it to be pretty dark so that the shiny collectibles are more punchy.

Problem:
The directional light I am using for sunlight outside of the tunnel somehow penetrates into the tunnel mesh, causing walls to be lit as if there were holes in the tunnel mesh, which there aren’t. Depending on culling settings, either one wall is lit or the other. When culling is disabled, there are still light leaks along the corners.

Question:
How do I completely shut off directional light from entering the tunnel? Can I disable the tunnel material from receiving directional light (but continue to receive other lights like spotlight)?
BTW, ‘contact’ settings alleviate the problem a touch but they kill the performance (which drops to 7fps with contact on)

:bust_in_silhouette: Reply From: Zylann

I had the same problem in tunnels seen in that video: https://youtu.be/Ec7OxZQi64E?t=28

By default Godot’s directional light casts shadows behind the visible side of a surface, and not in front it. So if you world is only a cave with surfaces facing inwards, the fact it has a ceiling won’t project shadow if the light is above it, since from the point of view of the light, the cave can be seen through.
Swapping the culling mode sounds like a good idea, but then famous shadowmap bias still lets light leak in…

As you can see in the video, I worked around this by covering the model with planes on top so that shadows will get projected in everything below it.