Particle Sorting Compute Shader Problems (RWBuffer feedback issue?)

Hi there!

I am trying to implement a Sorting Algorithm in a Compute Shader to use with particle systems.

My attempt was to simply port the OddEvenMergeSort from dottores Particle Lib.

Theoretically this is straight forward in code and patch.

But practically I got stuck with the buffer feedback.

In the compute shader I read and write to a RWBuffer, thinking that in theory that should be equal to a texture feedback as used in the example by dottore.

But it is not working (i cant observe a feedback effect here).
InstanceNoddles pack, uses in framedelay and framedifference a ping pong compute shader to swap the read/write buffer, i guess.

Is that the way to go also for internal Read/Write buffers?
Or any better idea that would enable reading last frames buffer from within the compute shader?

Or some ready made sort compute shader out there? :D

Here is my current implementation: (19.9 KB)

Well frame delay in that case is like an instruction to pass the param on next frame, I think if you try to pass the output back inside the shader you gonna pass it on same frame this called iteresation witch was a special hidden pin on shader node (dunno if it survived) but I was looking on sort shaders examples recently and thay were all using this iterations basically.

Ah I just saw that a “Itersation Count” exist in the shader.

Anyone with an example on how to use it?


@antokhio thanks for the explanation
was just wondering if there would be a more direct way. but yes its cool, i should be able to fix the problem using the framedelay nodes of kyle! J

EDIT: No its not possilble to use the framedelay from instance noodles, closed loops are somehow not possible.

I need to figure out how the iteration as indicated by the hidden pin is meant to be instructed.

Working all night long on it…

I tried to convert the buffer in a texture with a tFX from microdee (BufferToTexture)
And use Framedelay for textures.
This way it is possible to sample the feedback buffer in the compute shader with SampleLevel().

But it doesnt work correctly and the algorithm glitches away by sampling wrong values. Seems like it is caused from the BufferToTexture working only every second frame.
Patching a workaround for that is slwoly getting too hacky for my use case.

The algorithm works in general. I tested it against a readback and normal framedelay.

It realy needs “only” a framedelay for compute shader buffers, either in patch or as a code solution.

I hope someone can help here. What means the hidden pins “defines” and this “iterastion count” (should probably mean iteration count)

Files are here, probably needs MD.ecosystem and InstanceNoodles

OddEvenMerge_CS (25.9 KB)

Hi Guys,

It seems this weeks everyone is talking again for a way to sort in CS, I recently tried again bitonic and this example . i attached the test , it did not work but it complied properly. i tried in one and diferent passes but something must be missing. (6.0 KB)

also was recommended to check the radix sorting too

@tekcor not sure if understood well but for refeedback your buffer you have some old examples in the filtering nodes in here like the oscillator and decay refeedback the buffer. DX11 Modules And Shaders Addition II | vvvv

maybe our guru vux could light us up with some ideas and hints.

@colorsound this radix code looks cool
really wanna dive on that one, shame can’t find time yet

Hi colorsound,
Yes i also compiled the Bitonic Test the other day but jumped back to the other oddEvenMerge algorithm, because there i could at least understand how it works.

Now I have got it working, but with this hacky patched feedback loop by using a tfx that makes a texture fromt the buffer and framedelay.

It is slow as hell, mainly because the texture feedback works only with a preview.

I will better try to get that feedback in the shader working, Thanks for pointing out the example library (other libs)

Hi, I did further testing with the radix , i got this example working but only with 16 elements ;D . i used win10 and latest dx11 andvvvv_50beta35.2_x64 (9.1 KB)

Ah cool, and so funny that always there is some weird stuff appearing.

Same here, I also upload my implementations of OddEvenMergeSort for you to look at it.

There are two versions:

  • Based on Texture Feedback: works, but is slow and only works with preview open for the framedelay node.

  • Based on RW Buffer: has a data sink bug. Somehow the algorithm looses the particles over a certain amount of frames (or sets them all at index 0).
    So it works half way and needs some bug fixing and an idea where this data loss comes from (???) (19.9 KB)

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.