The output of the DX11.Particles Layer Emitter visually creates a grid (e.g. in emitter layer help):
I would like to connect the particles to lines, similar to this (which is"LineBuffered (DX11.Layer) help"):
But it seems like the position buffer is not sorted by the XY coordinates of the emitter. Using InstanceNoodles LineBuffered I just end up with jumbled up lines:
Is there any way to sort the buffer in such a way? Or is DX11.Particles just not the right tool for this?
Thanks so much in advance!
Due to the parallel execution of the compute shaders the particles are unordered by design.
If you need an ordering, you have to write a custom emitter where you introduce a new attribute (something like “customId” for example). The ids can be assigned with the help of the uv coordinates ( uint customId = uv.x + height * uv.y).
After the particlebuffers got rendered in the particlesystem node, you have to reorder the particlebuffer with a custom compute shader by the new customId. Perhaps you can have a look at existing post-buffer-render-nodes like AsAttributeBuffer or FiiterBuffer.
Unfortunately I have no time for that right now, so you have to try it on your own. But I am quite sure that it will work that way.
Thank you @tmp! Sounds good.
I attempted to write the IDs into the buffer. I think it’s generally working:
p.customId = texId.x + Resolution.y * texId.y;
To create the above I used a white FullscreenQuad to fill the whole camera view of the emitter. There is a weird pattern on the grid. I think it’s a bug related to the calculation of textId in the emitter and reported it here already: https://github.com/letmp/dx11-particles/issues/9
I hope this also explains why some of the IDs are doubled up and some are 0. Fixing the bug hopefully fixes those particle IDs too.
Regarding the sorting, I found this old thread Particle Sorting Compute Shader Problems (RWBuffer feedback issue?) - #5 by colorsound where people tried to get a few different algorithms going on the GPU. E.g. Bitonic, but they had issues. I had a play with those patches as well but didn’t manage to make them work. Any help would be highly appreciated!
I was also wondering if sorting the buffer is going to be super expensive?
The Particle Sorting in the other thread you mentioned was especially for sorting back to front z-order and would be not possible to adapt to your problem.
it could be that you are also a bit far out already with what you are trying and there might be a much easyer way to achieve what you actually want to do.
What is it that you want to achieve in the end? maybe we can find an easyer way to do it
Hi, i had a related problem with splines where i had to resort the format order of the buffer. Check in here there is a compute shader called sorter or similar there should be notes, you, ll find it. Maybe helpfull for your issue.
@jerry I just fixed the bug in the Layer Emitter. The correct assignment of ids should work now.
Thank you for your answers. I’m sorry for this very late reply. I’m actually back on the problem now.
@tekcor I’m trying to visualise reflected scan waves on objects. The layer emitter seems great to mimic that reflection. Only separate particles don’t seem to communicate the idea well enough. That’s why I would like to connect them as lines.
You might be right. This is probably at the edge of what DX11.Particles was made for. But I still have the feeling the aesthetics this would create are what I’m looking for.
@colorsound Thanks, I looked at your shader. It shows well how compute-shader work in vvvv in general. Unfortunately, I have no idea how to sort based on a struct property. :(
@tmp thanks for fixing the Layer Emitter. The ids are assigned properly now.
A friend recommended to me to move forward with CPU based sorting as far as I can. But I’m pretty sure I’m going to reach limits quickly as I planned to work with lots of particles.
Here is a working solution:
LayerLines.zip (14.3 KB)
This patch can also be used for a custom kinect emitter. All you have to do, is to write the pixel ids as new attribute into your particle buffer (in analogy to the provided custom layer emitter).
I uploaded both examples (Kinect & Layer version) on github: https://github.com/letmp/dx11-particles/tree/master/packs/dx11.particles/girlpower/Examples/Lines
@tmp Wow, thank you! That’s fantastic. That’s exactly what I was looking for.
And I think it looks really cool and it offers lots of room for visual experimentation.
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.