Search Unity

  1. Unity 2020.1 has been released.
    Dismiss Notice
  2. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Culling objects in specific shadow cascades

Discussion in 'General Graphics' started by theFrenchDutch, Aug 15, 2015.

  1. theFrenchDutch

    theFrenchDutch

    Joined:
    May 5, 2014
    Posts:
    25
    Hi !

    I have kind of specific request here that I've not seen brought up anywhere else : is there a way to specifically command which shadow casters are included during the rendering of each of the shadow cascades?

    To explain why : I'm currently building a terrain engine for Unity with the aim of very big scenes (life-sized landscapes). To get shadow on distant mountains I have the shadows setup with 4 cascades, distance 30km, and the first one or two cascades very close to the camera. The terrain is covered in forests and around the camera 3D trees are spawned (in a radius of say 100m) which cast shadows. I've noticed how activating shadows easily triples the amount of draw calls with those trees.

    Using the frame debugger, I checked how the shadowmap is rendered and I understood the "problem" : all of the 3D trees around the camera are rendered in each of the 4 cascades, while they are useful only in the first and maybe second cascade (as the 3rd and 4th one are always further away from the camera than 3D trees)

    Is it supposed to behave that way ? Basically I'd like for the first and second cascades to use the terrain and the trees, and for the 3rd and 4th cascade to use only the terrain. I really need a way to do this as the performance gain would be incredibly huge. Alternatively if it really isn't possible, does anyone have any source on how to implement a custom shadow mapping system in Unity so that I could do it ?

    Thanks a lot :)
     
  2. theFrenchDutch

    theFrenchDutch

    Joined:
    May 5, 2014
    Posts:
    25
    Actually I've played around more with the frame debugger and it seems that the trees are rendered in all 4 of the cascades only at some viewing angles, making my draw call count skyrocket, while they are only needed in the first cascade (trees are uselessly tiny for the 3rd and 4th cascades, invisible).

    I'm having trouble understanding how Unity decides which object to cull for each shadow map, and if there is a way to enforce it ?
     
  3. djarcas

    djarcas

    Joined:
    Nov 15, 2012
    Posts:
    154
    Did any solution come in this? Given that Instancing has virtually no culling associated with it, I would REALLY like to be able to do this.
     
unityunity