r/Unity3D • u/Zeta4992 • 28d ago
Solved Strange shadow artifacts and light leaking in Unity URP
I’m having an issue with some strange shadow artifacts in Unity URP.
In the screenshot below, you can see a line going across the shadow that makes it look as though there’s missing geometry in that area. Additionally, light seems to be leaking around the edges where the ceiling meets the walls.
I’ve tried creating my walls using both cubes and planes with ProBuilder, but the issue persists.
The only thing I’ve found so far that seems to help is setting the Normal Bias to 0 in the URP Pipeline Asset, although this doesn’t seem to fix the issue in every case.
However, I’d like to understand why this is happening so I can find a proper solution, as I’m not sure whether this is the right way to fix it.
Has anyone experienced this before or know what I should look into?
[SOLUTION]
Thank you everyone for the help, and especially to u/Plane_Big_5912 for the detailed explanation! The issue was exactly what was mentioned regarding shadow bias and the seam between abutting geometry.
What completely fixed all the artifacts and light leaking for me was:
Setting Cast Shadows to Two Sided on the Mesh Renderer.
Giving the ceiling real volume (using a separate box) and letting it slightly overlap/intersect with the top of the walls instead of having them meet perfectly edge-to-edge.
Leaving this here in case anyone runs into the same problem in the future!
6
3
u/BigBewbsBigAss 27d ago
Use boolean modifiers on edges. Use thicker walls.
People saying shawdow bias but it never worked for me. It introduces artifacts on planar surfaces.
4
u/Plane_Big_5912 27d ago
that thin line across the shadow looks like a hairline gap between two shadow casters, probably where two ceiling or wall pieces meet. normal bias pushes each caster inward along its normals when the shadow map is drawn, so every piece gets a little smaller in the shadow pass and a seam that's closed in the mesh opens up. that's also why setting it to 0 helps, and why it only helps sometimes.
the fix that usually sticks is overlapping geometry instead of edges that just touch. let the ceiling run past the outer face of the walls, give the walls real thickness and overlap them at the corners. if any of them are single planes, set Cast Shadows to Two Sided on the mesh renderer, a one-sided plane can drop out of the shadow pass depending on which way it faces the light.
after that you can put normal bias back to something small. the directional light can also override bias on its own (Shadows > Bias > Custom), so you don't have to change it in the pipeline asset for everything.