Particle system - Prototype running!



First prototype of the particle system is now up an running! It’s still a very much a bare-bones system, but a lot of what you might find in other open source particle systems has been already added. It took less than 10 days to go from no particle system, to a basic one that can serve as a skeleton for future work, so I’m quite satisfied.

Here are some highlights of what the system can currently do:

  • There are a bunch of emitter shapes available:
    Primitives like Sphere, Box, Cone, Rectangle, Circle, Line - And they all have a variety of customizable properties. e.g. for sphere you can control to emit from surface, volume or just a radius of some thickness. I’ll also be adding support for animated emission later on (e.g. emitting sequentially around a circle).
    Both static and skinned meshes - Now these haven’t been fully hooked up, simply because I haven’t yet exposed to the particle system with the rest of the scene, so they don’t have a connection to Renderable from which they would grab the mesh from. But internally a bulk of the work is done for emission on mesh vertex, edge or surface, with the ability to inherit mesh normals (and later on vertex colors). Especially skinned meshes should provide users with some really nice capabilities, and it will be fun to see in action.

  • Pretty much every property you can set on a particle system is a Distribution. When I say properties, I mean thing like particle color, size, rotation, etc. And Distribution means the property can be either:

    • a constant value
    • a random value in some range
    • a curve that varies over time
    • and two curves that get interpolated between using a random value

    It’s a simple concept but gives you a lot of freedom when customizing the particle system properties, and I haven’t yet encountered an open source system that gives you the same freedom. Being able to set curves that vary over time allow even simple properties to make complex behaviours - generally in other engines/frameworks you’d likely have a separate module with a set of properties to control something similar. But here it’s all nicely unified under the same system.

    For this addition I have also introduced a concept of Color gradients, which are essentially curves that interpolate between different colors, so your color properties can also nicely evolve over time as well. I will likely be adding support for color gradients directly on the Material, so you can animate any material color input.

  • Everything is multi-threaded, ensuring you can have many particle systems updating at the same time without incurring a heavy cost on CPU usage. The system was also designed the so the particles can easily be updated from the GPU, for even more extreme situations. Although GPU version is not implemented yet it’s good to have the design in place. In general multi-threading is a good thing to think about since the start, since its usually quite hard to add to an existing system, so I’m happy to have it in place.

That’s it for now. My next goals are:

  • Improve the particle renderer and make the rendering customizable (i.e. particle orientation, stretching, blend modes, etc.)
  • Add support for animated textures on particles. This will very likely be an update that will allow ALL materials in the engine to use animated textures in a simple, general-purpose way. I’m not sure if it will make it in this update but this will also involve GUI elements. I haven’t yet seen an engine that handles animated textures in such a unified way, so I’m pretty excited to see how it turns out!
  • Collision - Allow particles to collide and bounce off the world. This will most likely integrate with PhysX since it has built-in support for particle physics but it remains to be seen how nicely it plays with my own code - ultimately I might need to roll with a custom solution.
  • Add various evolvers - Evolvers are modules that allow you to control particles in special ways. Currently you can only control a particle system through basic properties, but different evolvers should allow you a lot more control. Also the system is fairly extensible, so adding your own evolver behaviors won’t be too hard.

And there’s a lot more after that, things like 3D particles, full on GPU particle simulation, and then a lot of potential optimization, exposing everything to user space, etc. Still a long road ahead, but quite happy to have something functional at this stage!

Until next time,