I’m building what is essentially a “top down” game with thousands of small static objects on screen, along with a couple of dynamic/moving objects, and a single directional light. The small objects are many duplicates of a few different low poly meshes. While GPU instancing appears to be an obvious win for this scenario, the shadow rendering is (understandably) consuming a very large portion of my frame time.
The shadows from all these small objects change around once per minute, so it seems silly to be rendering them every single frame. I’d rather not have to resort to disabling shadows for these objects, especially since they can just about maintain 60fps so I’m not orders of magnitude off here or anything.
The HDRP docs note Mixed Cached Shadow Maps as an option, and outlines almost my exact scenario:
The catch is, I’m not using GameObjects for these, so I don’t have a Renderer upon which to enable “Static Shadow Caster”… And creating objects for all of these is infeasible. Is there any way to do this with things like DrawMeshInstanced/RenderMeshInstanced? They only seem to take ShadowCastingModes of on/off and don’t have a static option. If I could use this mixed mode and submit the shadow data from my GPU instanced objects, I think I’d be all set, but I don’t see any way to do this.
Is there any way to GPU instance these in a way where the shadows don’t get redrawn every single frame? I’ve dug through a bunch of different APIs and none seem to fit all of my needs here. Or some way to essentially “bake” the shadows for my GPU instanced objects and then run the dynamic GameObject shadows over it?