Hey folks! I was trying to find a way to create a spray of particles from a sprite that closely matched the sprite’s contents but then flew off at random like particles, like this:
I found a few resources for Godot 3, but nothing for Godot 4 (which apparently made significant changes to how particle shaders are written), and I had zero experience with particle shaders, so I didn’t even know where to start. I ended up picking through and modifying a default particle shader to figure out how to create my own.
You can check out the result here!
In the process, I read through and reformatted a “default” shader that Godot generated from its ParticleProcessMaterial, since I couldn’t find any full particle shader examples online. I added a ton of comments as I worked out what it did, and I removed some extraneous variables that weren’t actually in use and moved others that were being declared really far from where they were needed, so if that sounds helpful, it’s here as “default_analyzed.tres”.
This is still pretty primitive! I intend to keep working on it, and I’m sure experienced shadersmiths could take this and do a lot more interesting things with it very quickly. I mainly hope it’s useful as a learning tool and starting point, and a way to save time for others.