Compute Shaders: Fire particles
After working on the grass rendering system I wanted to try out more stuff with compute shaders, so I decided to try to make a cool particle system. I wanted to make a system that could handle more that 1 million particles, and also have (or at least give the illusion of) volume. I also wanted to a mesh emitter, so that you could basically set things on fire.
The main setup of the system is shown in the image below. A mesh is passed into a compute shader, which uses curl noise to move the vertices. The result is stored and incremented on in a RWStructuredBuffer. This is then used in a geometry shader, which creates colored geometry from the positions in the buffer.
In the image above you will see a sphere mesh being used as the emitter, but you can actually pass in any mesh that you want:
There is still work that needs to be done with this system, since it takes too much performance if you zoom in on the fire. You also cannot rotate the emitter at the moment. I’ll try to fix this when I get some time over. The base setup for the curl noise movement is based a gist by Yuma Yanagisawa (see Sources below).
Source code
Sources
Curl noise particles by Yuma Yanagisawa
<https://gist.github.com/ya7gisa0/742bf24d5edf1e73b971e14a2553ad4e>