Search Unity

Stable fit shadows

Discussion in 'General Graphics' started by iivo_k, Mar 29, 2016.

  1. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    I've noticed that when using the stable fit shadow projection, shadows start fading out the further they are from the center of the camera, making stable fit unusable in several cases. Now the documentation mentions nothing of this:

    Can someone explain why does it happen? Is it something inherent to the technique or a bug?

    Too lazy to create screenshots, so here's someone's unanswered unity answers post from a year ago with pictures:
    http://answers.unity3d.com/questions/923354/shadow-projection-issue.html
     
  2. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Pinging @Aras for insight about shadows.
     
  3. Aras

    Aras

    Unity Technologies

    Joined:
    Nov 7, 2005
    Posts:
    4,770
    Stable Fit projection basically does each shadow cascade as a circle, centered around some point. So that when camera rotates, the shadow size/resolution can stay exactly the same, with no "shadow edges swimming" artifacts. And since it's a circle, the shadow face-out range is circular too.
     
    warthos3399 and Arsonistic like this.
  4. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    So is there any way to have stable fit shadows working on the edges of the screen? None of the quality settings seems to have any effect, doesn't matter if cascades are enabled or not. Can the circle size be increased or something?
     
  5. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    The cascade splits and shadow distance should control that.
     
  6. iivo_k

    iivo_k

    Joined:
    Jan 28, 2013
    Posts:
    314
    Like I said, nothing in the quality setting has any effect. No cascades, 2 or 4 cascades, shadow distance from 10 to 300, doesn't matter. Using orthographic camera with size 10 in this case.
     
  7. jstine35

    jstine35

    Joined:
    Dec 23, 2017
    Posts:
    3
    Stable Fit shadows depend on the camera's projection depth information to work their magic. Orthographic Perspectives do not have a valid concept of depth, which is why Stable Fit shadows behave erratically when paired with Orthographic Cameras. The appropriate fix in this case is to disable stable fit. The problem stable fit shadows are meant to fix doesn't occur in a typical orthographic gameplay situation anyway (eg, rotations of a scene, changes in depth).

    I would also suggest turning off cascades (set to 1), since those also depend on camera depth information that orthographic projections lack.
     
  8. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    Working with perspective camera here.
    Expanding further the Clipping Plane works, but in our case that would be a performance problem.
    Turning off cascades doesn't do the trick.
    Any other ideas?
     
  9. pistoleta

    pistoleta

    Joined:
    Sep 14, 2017
    Posts:
    539
    @Aras any news on this after 7 years :D
     
    Ajasmm02 and Torantulino like this.
  10. Lucuxis

    Lucuxis

    Joined:
    Aug 10, 2021
    Posts:
    1
    any news on this after 13 years :D