Blog

Spark compute particle shader

This is made using Unity, the particles are all simulated on the gpu with a program i wrote in HLSL using compute shaders, then rendered with a shader i wrote in cgfx. 

I tried to write the system to be as versatile as possible, so you can edit a whole myriad of properties in engine as its running. My next step is to add full geometry collision.

I'm pretty proud of it for now, it has collision/physics with the ground plane, the plane also gets illuminated by the sparks when they collide if the sparks have enough energy, the sparks lose energy over time which causes them to glow less and eventually turn grey, The system looks pretty with the HDR glow and other effects. I'm working on giving the system collision with any geometry as well, I reckon I should have that done within the month.

Screenshot (29).png

The performance is solid as well. For most of the video Im making a solid 150 - 300 fps with around 30-50k particles (which are actually semitransparent as well). The occasional stutter or speed up was due to my recording software not being able to record flawlessly at the bitrate that a million little particles required, but without the recording software I was able to get the same results minus the stutter with 100k+ particles.

A lot of the algorithm that I used to handle spawning/simulating/particle death were inspired by the methods laid out by Gareth Thomas in these slides: 
https://www.slideshare.net/DevCentralAMD/holy-smoke-faster-particle-rendering-using-direct-compute-by-gareth-thomas

 

You can find the source for this project here: 
https://github.com/TarAlacrin/SparkParticleSystem