Drawing to shadow map using command buffers

We are using Graphics.DrawMeshInstancedIndirect at the moment, and that works. But this has some performance overhead i’d like to avoid, by using CommandBuffers. The list of objects to render doesnt change in runtime, so making the commandbuffers once should be faster than calling the Graphics method every frame.

I can easily draw into the right stage in our deferred renderer using AfterGBuffer, but i’m stuck on how to draw correctly to the shadow map. When i add my “Indirect Shadow” buffer to either Before or AfterLighting its not inside the Shadows.RenderShadowMap phase.

7751361--975294--upload_2021-12-20_22-18-36.png

There doesnt seem to be a ShadowMap CameraEvent. Am i missing something obvious, how am i supposed to be able to draw into the shadow map using command buffers?

Ah! Gottem, need to add it to the light and use a LightEvent.

Almost there!

1 Like