Forum

Select Vertices in compute with AppendStructuredBuffer

hi all,

I deform a tesselated plane and draw lines onto it. I want to use the vertices of my lines for the particle emitter.

gamma

in compute - sample the texture, and add vertices within the bright areas to an
AppendStructuredBuffer and feed this into the probability emitter.

I modified the BufferFlags from ComputeBuffer to set it to “AppendStructuredBuffer”.

fuse emitter does not allow for direct buffer input yet, so I have to readback and create a new buffer. just for testing - in the end I want to input the compute buffer directly into the emitter.

I also stumbled across this thread: DX11 Appendable Buffer count sticks at high level

“Append buffers are fixed size, so the real (or maximum) buffer size is always the one specified in the Element Count pin. Append buffers hold an internal counter which is then used for processing only “valid elements”.”

So I was wondering - is the buffer size in the debug window not changing because the AppendStructuredBuffer is fixed size? but actually it contains each frame a different number of my “valid” vertices. how do I later on process just these? or should my append buffer have a different element count each frame?

how do I setup my buffer correctly to get this working?

in this case, I would simply attach a value to each vertex that specifies whether it is an emitter or not and then use that in the particle simulation to emit or not. this is much data/gpu friendlier than changing buffer sizes or handling complex count logic.