0 votes

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)

in Engine by (422 points)

1 Answer

0 votes

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.

by (27,902 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.