How to draw mesh instanced with ScriptableRenderContext?
I'm new to scriptable pipeline methods on MonoBehaviours, I'm trying to render multiple meshes using CommandBuffer.DrawMeshInstanced
but I don't know the correct way of doing so.
Right now I'm using the RenderPipelineManager.beginCameraRendering
to render the meshes, create a new CommandBuffer
, add the DrawMeshInstanced
command with the arguments: cmd.DrawMeshInstanced(_mesh, 0, material, -1, matrices, _numAliveParticles)
being _mesh
a quad, material
a default lit material, matrices
the array of Matrix4x4 representing the instances transformations and _numAliveParticles
the number of instances to be drawed.
Then I use the ScriptableRenderContext context passed to execute the command buffer, then release the command buffer and call ScriptableRenderContext.submit().
This is the order of things that my render method is doing, but nothing is being displayed on screen, I already enabled gpu instancing on my material. I'm missing something?
Your answer
![](https://koobas.hobune.stream/wayback/20220613052203im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Graphics.DrawMeshInstanced Doesn't work with transparent materials 1 Answer
Graphics.DrawMesh Leaking Mesh Memory 1 Answer
Draw multiple material using Graphics.DrawMesh 0 Answers
Did the new scriptable render pipeline system break Graphics.DrawMesh()? 1 Answer
Trouble with Dynamic Batching 0 Answers