Hello,
Lately I’ve been experimenting with using the compute shader to do procedural generation. Originally I was using the default type to return the results (textures or geometry) to the CPU which would work fine for the most part but when it came to geometry, I would have to do some cleaning before setting it as the mesh.
When I went on to the append type, the results don’t always seem to be returned when I call GetData(), sometimes Ill run it and it works perfectly (I’m using 2 append buffers, one for vertices and another to keep track of the number of verts being returned) so the mesh is created and other times they’ll return all 0’s, no error from the function itself, just when it attempts to apply it to the mesh.
sample of how i’m using the buffer in the .compute
AppendStructuredBuffer<float3> verts1 : register(u0);
AppendStructuredBuffer<int> count : register(u1);
...
count.Append(c);
and the .cs
verts1 = new ComputeBuffer(chunkSize[0] * chunkSize[1] * chunkSize[2], 12 * 15, ComputeBufferType.Append);
cs.SetBuffer(k[kernels.CSMarch], "verts1", verts1);
count = new ComputeBuffer(chunkSize[0] * chunkSize[1] * chunkSize[2], 4, ComputeBufferType.Append);
cs.SetBuffer(k[kernels.CSMarch], "count", count);
...
int[] c = new int[chunkSize[0] * chunkSize[1] * chunkSize[2]];
count.GetData(c);
If anyone has any idea what this may be caused by or a solution, any help would be greatly appreciated.