Directional Light Shadow fails underground / light shows underground

Hi,

I have made a procedural voxel game prototype, where the chunks are in all directions (x,y,z).
You can see when I go underground, around 29s, that everything looks fine. Then I drop deep undeground and you can see around 39s that the directional light is shining.
Shadow distance is set to 500.

Why does the directional light show?
ps. The dimmer light is flood-fill artificial light, propagated by flood-fill.

Kind regards,

Are the models closed on both sides? That might be needed for Unity’s shadow system

Hm… they are procedurally generated chunks. So, initially they may have both sides.
But if you go deep underground, only the inner faces, like the cave walls would be rendered, as dirt & rock on top of the cave, would be way too think and the opposite face would be out of render distance.
So yes, from the light’s point of view, it could pass right through, when the “walls” don’t have both faces. Hope there’s a setting for this, without having to render faces both ways…
I found it useful to use directional light on top of voxel light - because it looks nicer.

Edit. Seems not to be the issue, as it works in some places and doesn’t in others?

Edit2: Seems to be exactly the issue. If I delete the stuff from high on top, it all becomes lit

Before and after top deletion here:


Kind regards,

I hope someone has a solution for this, otherwise I will need to discard the directional light… and I would very much like to keep it.

TLDR. Light shines inside a room, if the outer sides of the walls are non rendered.

Kind regards,

Check your render debugger to see what the shadow camera see’s.

You may be able to get away with enabling both sides of the mesh cast shadows?

Maybe consider a bug report for a solution.

1 Like

Well, you actually led me in the right direction.

Setting “Cast Shadows” to “Two Sided” solved the main issue.
Now I only remain with a minor light bleed here and there.

Kind regards,

1 Like

this is probably a bias or normals shadows setting issue.

If using URP the Umbra Shadows asset adds contact shadows which can help with this aswell, but i’d only reccomend that if the bias and normals settings to fix this conflict with something else.

1 Like

The provided screenshot already has the bias and the other one set to 0.
Increasing the resolution to 8192 helps - I tried a bunch of settings, but I cannot get rid of the small glitches completely.
But, I seem to be on the right track.
Thanks!

Kind regards,

1 Like

Yeah it might be a resolution issue, one solution can be reducing shadow distance or adjusting cascades.

Shadow filtering for soft shadows can cause this too i think.

But yeah maybe try Umbra Shadows.

1 Like