Search Unity

How to avoid Shadows fading when close to clipping?

Discussion in 'Shaders' started by benjaminthorn, Aug 20, 2019.

  1. benjaminthorn

    benjaminthorn

    Joined:
    Mar 9, 2018
    Posts:
    19
    Hi, Unitys starts fading of Shadows on Objects that get closer to far clipping Plane.
    Anyone an Idea how to avoid that?
     
  2. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    152
    You can increase the shadow distance setting in the quality settings, but they fade out for a reason. Shadowmapping relies on textures of a specific resolution; if you increase the distance the shadows need to cover, you will lose a lot of detail the shadow map holds. If you really need to increase shadow distance to a large value, I would suggest also using shadow cascades (probably 4) and decreasing the ratio of the first few cascades drastically (also in the quality settings). That way you will get normal quality shadows close to the camera, but lower quality shadows further away.
     
  3. benjaminthorn

    benjaminthorn

    Joined:
    Mar 9, 2018
    Posts:
    19
    shadow distance does not apply if far clipping plane value is lower
     
  4. Namey5

    Namey5

    Joined:
    Jul 5, 2013
    Posts:
    152
    I assumed you had a large far clipping plane, but you're right. For performance and quality reasons, shadow distance is capped to the far clipping plane. As far as I'm aware, the only way to remove fading at the far end of the shadow distance would be to use a custom shader and manually sample the shadowmap yourself.