Hi,
The DrawMeshInstancedIndirect API in 5.6 is really awesome! I’m building a system now which has to take an object, and then draw it in a NxNxN grid (so N cubed) times.
To do so I fire of a compute shader that checks each NxNxN positions and frustum culls then. if the position is visible it’s added to an Append Buffer. Then I use DrawMeshInstancedIndirect to draw all positions in the append buffer.
This all works great but has a major caveat. When renderering shadows objects that are frustum culled don’t cast shadows either of course. Really what needs to happen is that the culling compute shader needs to run before each rendering pass - not just before the main rendering pass.
What I maybe could do is rerun the compute shader just before shadow rendering assuming unity reads an up to date representation of the buffer. However - in a compute shader there is no way for me to know the unity_WorldToShadow matrices or the total clip planes of the shadow rendering camera.
Any advice on how to achieve compute shader based culling with DrawMeshInstancedIndirect would be greatly appreciated!
Best regards,
Arthur Brussee