currently I am writing a compute shader, which implements marching cubes. But I am still struggeling about some questions about how to get the triangle information or some other dynamic data out of the compute shader.
In my opinion there are two ways:
- Create a big enough SSBO (I think, now it is also possible to create one with dynamic size, but I am unsure about that) and use an atomic counter within the shader to write my data into the buffer. But I think, that this is very inefficient because of the atomic counter.
- Do the marching cubes stuff in several steps. At first, get the case and save the number of triangles in a texture or some other buffer. Then. use the prefix sum to get the number of triangles. Create a buffer accordingly to that sum and let each shader write its triangle information into the buffer.
I know that the two ways are not described in detail, but it should be enough to understand the idea. My question is now: Are there other good possibilities to get the information out of the compute shader, which I do not know?