Having more control over shadowmap and cascade rendering ?

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)

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 :slight_smile:

Hmm sorry it might be the wrong place to ask about this actually ?