Search Unity

Question Light passing through seams on mesh edges (real-time lighting)

Discussion in 'Global Illumination' started by Phil_42, Nov 18, 2021.

  1. Phil_42

    Phil_42

    Joined:
    Mar 15, 2017
    Posts:
    6
    Hello

    In my scene I only use real-time lighting and all meshes are generated at runtime. Basically I have a very simple room where the floor, ceiling, and all walls are connected planes with the "two sided" shadow casting mode. So in theory, no sunlight should be able to enter the room. What is happening in reality, is that on the edges (where the walls meet the floor, ceiling and each other) some artefacts appear. The light is passing through the seams.

    light_artifact_normalbias_06.png

    I was also able to recreate the problem with the Unity standard planes (new > 3d object > plane). Arranging 6 planes with 2-sided shadows to make simple room makes the light artefacts appear as well. This means it's probably not the fault of the generated meshes.
    unityplanes_light.PNG

    I've seen this problem described in other threads such as: https://forum.unity.com/threads/light-passing-through-mesh-at-seams.641449/

    I have already tried multiple approaches, such as changing render quality, changing the biases of the directional sunlight, changing the resolution of the directional sunlight, changing/turning off ambient lighting. Nothing has helped to get completely rid of the artefacts. The thing that helped the most was changing the bias and normal bias of the directional sunlight to 0. Here is how it looks with biases set to 0. Notice how the lightbeam is smaller and at a different position now, but still there.

    light_artifact.png

    I somehow feel this is a very basic problem, but I am not experienced with lighting and I'm out of ideas of what else I could try.

    Any help is appreciated
     
  2. kristijonas_unity

    kristijonas_unity

    Unity Technologies

    Joined:
    Feb 8, 2018
    Posts:
    1,080
    This is an inherent limitation of shadowmap rendering. Take a look at this manual page for more information: https://docs.unity3d.com/2019.2/Documentation/Manual/ShadowOverview.html

    I would suggest tweaking shadow bias settings, along with the shadow distance, and cascade count.

    Leaks such as the one you are seeing are common when modular meshes fit snugly together. I would suggest making your meshes larger, so that there's more overlap as they intersect. Alternatively, you could model a shadow blocker cage mesh to block all the light from the outside.
     
    Phil_42 likes this.