Hi everyone,
I’m looking to generate a standard mesh through a compute shader. The compute shader will write output (position,normals,texcoords,colors) into (append) buffers. I want to use these buffers in the standard unity graphics pipeline, but without a read back to the CPU. Since the mesh data length isn’t constant, this means I have two options:
- Append zeroes to get degenerate triangles in a fixed length buffer, and then I can dispatch a fixed size call on the CPU. Since the call is fixed, I think I can use all the default classes (Mesh/MeshFilter/etc), although they might not give access to the underlying GPU buffers.
- Copy the append data into a DrawIndirect buffer, and use that for rendering. I would need to use Graphics.DrawProceduralIndirect. However, then I need to setup the entire pipeline myself (setup materials/shaders/bind bufffers/etc).
Ideally I would like to use the second option, but I am at a loss on how to combine this with the standard rendering pipeline. Once the mesh data is generated I want to be able to treat it as a regular mesh (setting material on it, using it’s transform etc). Is there anyway this is possible, other than essentially rewriting the standard shaders? What I’m really looking for is a Graphics.DrawIndirect() call, but that doesn’t exist as far as I can tell.
Kind regards,
Rick