Hi, I have a question about some lighting issues in this scene. There are strips of light where there shouldn’t be being cast by the directional light. (Next to the windows.)
Details:
We are utilizing the Universal Rendering Pipeline, and I’ve applied a mixed lighting approach where some details are baked like ambient occlussion but I also rely on reflection probes since many of the textures are metallic. In order to solve a different issue, I used the URP pipeline asset to set the normal bias and depth bias to 0 under the shadows section. It seemed to help this issue somewhat actually, since it was more pronounced previously, but not all the way.
The meshes all have thickness and there are no gaps. I’m not an expert in lighting, so I’m not sure how to resolve this issue, and am looking for some advice on how to address this.
It’s hard to be sure what is going on based on the information given but here are some things to try.
Is the lighting coming through the windows for the simple fact that they are transparent? If so, that sounds like the expected behaviour to me. Let me know if I’m misunderstanding anything here.
What happens if you move a opaque box in front of the “windows”?
Try playing with the window material. What happens if you change it to be fully opaque?
You can try inspect the generated shadow map using Unity Frame Debugger (Unity - Manual: Frame Debugger). Do you see something unexpected there?
Necroing because this is the only place I’ve seen this problem described and believe I have some useful info for others that find this:
In my very similar case where a normal map on an inside wall got specular reflections from the directional light outside, changing the shadow / normal bias values didn’t help at all and setting the wall to cast “two sided” shadows helped very little.
I seem to have identified two things that can cause / intensify these “light leaking” artifacts:
One is the normal map strength in the material and “sharpness” or frequency of the texture (when neighboring pixel values differ strongly). Decreasing the normal map strength below 1 and even slightly blurring the texture helped me reduce the artifacts. Beware though that blurring normal map values isn’t the technically correct way of “smoothing” neighboring vector values together and you lose small details - this was just for testing and for the overall visual result.
The second is that for surfaces that receive light but should be in shadow, the shadow caster is too close to them (along the light direction). In other words, the shadow map resolution is too low to correctly resolve whether a fragment being shaded is in front of or behind a shadow caster as viewed from the light source.
A quick test whether this is what causes the “light leaking” is to put a cube between the light source and the problematic area so that it casts a shadow there (so in this case, on the outside of the curved part of the wall left of the window receiving the blue specular reflections) - this should greatly reduce the artifacts.
Increasing the shadow map resolution can help mitigate this in some cases, but is generally a bad idea because it’s expensive and might even be impossible given platform / memory restrictions.
For a static scene / light origin, the better but more involved “fix” is to either edit the mesh thickness, or add additional objects with a lit shader and “Cast Shadows” in the Mesh Renderer set to “Shadows Only” to ensure the shaders pick up the shadow in places that get this “light leaking”.
I have had trouble getting these extra shadow casters to cast shadows where they logically should though, something I have to investigate further as I can’t make logical sense of this behavior. EDIT: the objects were too large and messed up the shadow map cascades, breaking them up into multiple smaller ones worked.