Search Unity

Poor shadow frustum fitting?

Discussion in 'General Graphics' started by bluescrn, Jan 17, 2018.

  1. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    Hi,

    I've noticed that the size (and therefore resolution) of the shadow frustum for a directional light is related to not just the active shadow casters, but also the shadow receivers?

    Is this normal/expected? - It seems to result in unnecessarily low-resolution shadows when you only have a single shadow caster (or small set of shadow casters) on a large area of ground.

    The images below show a minimal test scene close-fit shadows, low resolution, no cascades. The cube is the only shadow caster, the plane is just a receiver (Other info: Unity 2017.1.1.p4, running in PC standalone mode. Shadowmap contents have been copy+pasted on from the frame debugger)

    The only difference between the two images is that the ground plane has been made much larger in the second image - resulting in very inefficient use of the available shadowmap resolution. (The shadowmap from the first image should be perfectly usable to render the second image, so long as shadowmap reads clamp to the edge of the texture. And the shadowmap in the first image could have had a much tighter fit around the cube to begin with?)

    Is this expected behaviour? And is there any workaround for this? - perhaps to manually set the shadow frustum to be a tighter fit around our known shadowcasters?


    shadowfit_1.png shadowfit_2png.png
     
    Last edited: Jan 17, 2018
  2. bluescrn

    bluescrn

    Joined:
    Feb 25, 2013
    Posts:
    642
    I'd still love to be able to control the 'shadow camera' from script...

    I've worked on a couple of mobile projects that have had a UI screen primarily to show off a character/vehicle/weapon model, and it's the only thing casting shadows (onto itself and some sort of ground plane). It'd be great to be able to use the shadowmap resolution more efficiently, especially to allow for better quality self-shadowing.

    (I guess I could do the shadowmapping myself and disable Unity shadows, it'd just be a rather more time-consuming process...)