# Distance between stride particles?

Hi all!
Starting to venturing in GPU stuff (quite scary really!). I was wondering: would it be feasible, in the Stride particle system calculate the distance between every particle? Say I want to change colors of the particles based on their reciprocal distance? Is it the right approach? Should I instead look into Geometry shaders? (i’m quite confused at the moment really!)
Thanks a lot for any answer! I always appreciate your patience and knowledge guys!

it is possible but rather complicated to achieve on the GPU. the most simple brute force method is to create a huge buffer that contains all particle pairs. so if you have 1000 particles, the buffer would have 1000x1000 = 1Mio entries. then have another shader that calculates the distance for each pair. then in a third shader, you can use this information to do something with the original particles.

then you can start to add several levels of optimizations, for example, you only need to compare A → B but not B → A and not A → A and not B → B. that means the pairs buffer can have less than half size.

however, as a start, I would choose a simpler task that doesn’t involve multiple shader passes.

I see your point!! Thanks a lot!
I guess probably to have many particles connected I could instead try using stride instancing instead of starting from a particle system…?
Anyway thanks a lot for the suggestion of not approaching this problem as a start!

That depends, on amount of particles you have, can give you to vvvv examples, one simple: