I’ve been playing around with Graphics.DrawMeshInstanced() and it works nicely. I read a post somewhere that said it’s better to use CommandBuffer.DrawMeshInstanced(). It seems to work (no errors, and stat’s says it’s rendering tris/verts etc) but it’s not visibly showing on the screen.
I’m using a standard material with default shader and GPU Instance enabled. I’m assuming I’m doing something wrong?
Simplified version of how I’m executing the code.
commandBuffer.Clear();
commandBuffer.DrawMeshInstanced(mesh, 0, material, -1, matrices, matrices.Length);
Graphics.ExecuteCommandBuffer(commandBuffer);
Did you set the view and projection matrices for the command buffer?
This was a while ago now.
No. All references I’ve found in regards to using CommandBuffer stated that it can be used just like the Graphics API. There was never a mention of setting the view and projection matrices. That link, however, does mention something rather important.
This function is compatible with the Built-in Render Pipeline. It is not compatible with the Universal Render Pipeline (URP), the High Definition Render Pipeline (HDRP), or custom Scriptable Render Pipelines.
I believe I was using URP at the time. I wonder if that was the issue.