- Home /
How does one do compute shaders(with particles)?
So, this is my first attempt at compute shaders and I'm quite lost... ANY help or referral is higly appreciated.
My goal is to achieve an effect that I've only been able to identify as "plexus" or "plexus particles". They look like this;
... Or this;
But nevermind all that, my approach is to get the positions of all the particles in the particle system, then I'll pass that array to my compute shader that can compute the distance between them, and then check which particles are close enough together to create a line between them.
Most important is probably to improve my understanding of compute shader syntax and workflow. Any example code would be nice.
From here on out it's more of a "nice to have" deal.
I'd like to define a threshold for how many lines or connections any particles can have as well. If possible I'd like it to output a position and scale for a billboard particle to function as the line between two particles.
By the way, i know there are easier and probably better ways to do this, but I'd like to at least use compute shaders, as learning them is the goal of the project.
Again, thanks for any type of help!
Answer by tanoshimi · Jul 11, 2017 at 06:15 AM
Compute shader syntax in Unity is regular HLSL. Here's some starter examples:
https://en.m.wikibooks.org/wiki/Cg_Programming/Unity/Computing_Image_Effects
https://en.m.wikibooks.org/wiki/Cg_Programming/Unity/Computing_Color_Histograms
https://en.m.wikibooks.org/wiki/Cg_Programming/Unity/Computing_the_Brightest_Pixel