#Rendering without a MeshRenderer

1 messages · Page 1 of 1 (latest)

toxic pecan
#

I generate a mesh and apply a material to it with a shader written in HLSL.

The only purpose of this mesh is to be rendered. No physics, no scripts.

When generating this mesh, a lot of time is wasted waiting for the data to be sent from the GPU to the CPU, which I know is generally something you want to avoid.

computeShader.SetBuffer(vertexKernelID, "vertexBuffer", vertexBuffer);
computeShader.Dispatch(vertexKernelID, GetThreadGroups(vertexKernelID, vertices.Length), 1, 1);
vertexBuffer.GetData(vertices); <- Here

computeShader.SetBuffer(triangleKernelID, "triangleBuffer", triangleBuffer);
computeShader.Dispatch(triangleKernelID, GetThreadGroups(triangleKernelID, triangles.Length / 6), 1, 1);
triangleBuffer.GetData(triangles); <- And here

Is there a way to just render it without sending anything back to the CPU?

foggy sparrow
#

solution is probably to use a compute shader + DrawProcedural

whole ermine
#

Writing to the mesh buffers in a compute shader is a little more complicated than writing to StructuredBuffers, but not too bad.

toxic pecan
#

Also would keeping the MeshRenderer have an impact on performance?

whole ermine