I am trying to render an enormous amount of movable meshes, and I figured the most optimized way of doing this would be to:
- Process all the mesh data and send it to a shader via StructuredBuffers
- Do a Graphics.DrawProcedural of all vertices using that material/shader
- On update, simply update the StructuredBuffer containing the transform matrixes of every individual object, and let the shader handle positioning all the vertices to match the movement.
Right now, most of it is working decently well, and I can render a massive fully-destructible city in only 6 draw calls:
This method makes the difference between 1 fps and 140 fps for 1000 buildings each containing 100 fragments.
However… after 2 days I have not been able to figure out how to do a decently lit/shaded deferred shader that works with DrawProcedural.
I do have a custom deferred shader that works well when using the usual vertex shader input structure, but as soon as I try to convert this to StructuredBuffers of positions, normals, uvs, etc…, all lighting is lost. Is there any working example of this?