I came across this note in the unity docs.
What Unity API do I use to “create a single buffer that contains mesh information.” What would be the recommended method for rendering particles/billboards?
I came across this note in the unity docs.
What Unity API do I use to “create a single buffer that contains mesh information.” What would be the recommended method for rendering particles/billboards?
The recommended method for particles is VFX Graph or Shuriken. VFX Graph can handle millions of particles without breaking a sweat.
For LOD or tree billboards, unless you have 1,000+ on screen at once just let the rendering system do its thing and don’t worry.
If you want to go down the rabbit hole, the suggested way is probably to get a CommandBuffer, pass some data from your app in a ComputeBuffer, use a ComputeShader to generate vertices, and then call DrawProcedural (or DrawProceduralIndirect) so it’s just a single draw call instead of many instanced draws.
The main use case would be grass, because Unity’s terrain grass rendering does not scale, but there are several grass assets that already do this on the asset store with various levels of quality. So it’s only worth doing yourself if you want to achieve a particular style/look with your grass (or for learning purposes).
For DrawProcedural and DrawProceduralIndirect, the Unity docs now say:
RenderPrimitives and RenderPrimitivesIndexed docs both say that they use GPU instancing. Is there a different method that doesn’t use GPU instancing that is recommended to render a mesh with a low number of vertices many times?
I’m also curious about this - I just want to draw a lot of quads efficiently, so I’m just looking for some sample code of how to “create a single buffer that contains all the mesh information and use that to draw the meshes”, as the GPU Instancing page says to when meshes are less than 256 vertices.
Use the Mesh class, passing a single vertex/index buffer containing all your individual quad’s data.
Alternatively, if you’re rendering a lot of instances of the exact same mesh you can use GPU instancing.