Question

I have a compute shader generating hundreds of thousands of paths for me (e.g. GL_LINE_STRIPs) of size 128 each. I'm storing them all in a big SSBO and I'd like to render them.

[x1 y1 x2 y2 ... x127 y127] //path 0
[x1 y1 x2 y2 ... x127 y127] //path 1
...
[x1 y1 x2 y2 ... x127 y127] //path n

Is there a good way to render this? Originally I was thinking with primitive restart, but multiDrawArrays might work too? I don't want to send hundreds of thousands of indices along with the draw call.

Seems like storing another array on the GPU for indirect rendering would work too? I was just wondering if there was something like a "primitive restart every 'm' vertices" kind of function.

Was it helpful?

Solution

Since you're pulling the vertex data from an SSBO rather than a VBO and each path has the same number of vertices, perhaps attribute-less instanced rendering is what you need?

Bind an empty VAO and call glDrawArraysInstanced(GL_LINE_STRIP, 0, 128, n) (where n is the number of paths). In your vertex shader, calculate gl_InstanceID * 128 + gl_VertexID to get the index of the current vertex in the SSBO.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top