URP -> Is it possible to Calculate Shadows on dynamic object only when the object is moving ?

Hi I’m trying to think of some optimization. I want to make it so shadows for dynamic objects are calculated only when I’m moving the object itself and not when the object is idle.
For example → check game you calc shadows only you move the figures ?

Thanks in advance !

What you are referring to is commonly called shadow cache, and URP doesn’t implement it. Maybe HDRP? But not sure. It would be a nice feature to ask for.

Hi @PacoChan Thanks for reply, anyone else knows how to be implemented ?

I don’t think it’ll be trivial to do, but would require URP’s shadow casting to be modified. You’d have to duplicate the behaviour of MainLightShadowCaster, and render a shadow map for stationary and dynamic objects, then combine them together before passing it to shaderland.

You’ll need a system that keeps track of which objects are stationary and moving. As well as an event for when one switches states, since this requires to re-render the “static” shadow map. Assuming it’s just for one directional light, it needs to be re-renderer when it moves as well. But this is all very similar to using baked lightmaps for static objects, and realtime shadows for dynamic objects.

HDRP uses shadow caching, and has all the bells and whistles in place. So it’s technically possible to reverse engineer everything, but it’s a likely ton of work and peers into the realm of making a custom URP version.

2 Likes