Particle engine

I know your point here is more about the cloud, but have you considered using lines instead of points for the rain? I would think it may help get a fake motion blur.

1 Like

@gui thanks, that’s a good point. The engine doesn’t handle anything other than sprites, so lines would be impossible in the current state. I do have a trail renderer, but there’s not easy way to connect the two.

A lot of particle engines on the marker separate simulation and rendering parts, where rendering is a plugin that goes on top and feeds from particle data. This way you can choose how to render your particles, as sprites, trails, meshes, lines etc.

I think that’s a great approach, but I do not have this implemented in my engine, sprites are all you get :smiley:

1 Like

Sweet soft particles cloud! :star_struck:

1 Like

I spent yesterday re-writing my texture atlas code to work incrementally both in terms of paint and layout. The work is complete and I’m happy to say that it takes a fraction of a millisecond to paint a new sprite onto the atlas now, including the finding the place for it. The Atlas also has a small adjustable cache which allows sprites that are not currently in use to remain painted. This way thrashing of the atlas is reduced significantly. I found that in my game all the sprites basically sit in the cache or are in use, so after a certain point the canvas is not being updated anymore as everything is on it. Here’s a small video with the atlas debug visualization overlayed on top of the game screen.

you might notice that as I click on the ground and a particle effect is spawned - it requests a new sprite, which is immediately painted onto the canvas, same when the chest opens.


@Usnul that is absolutely AMAZING! If you’d like a beta tester for the weather simulation, count me in! :slight_smile:

1 Like

I made a small demo of particle sorting.

there are 1500 particles in each “cloud”, sorting on my machine takes around 0.5ms per frame.

1 Like

@Usnul : Wow! Good job! Keep up the great work! :slight_smile: Do you mind open-sourcing it instead of using a webpack? I would like to continue to beta test this! :slight_smile:

Hey @Aerion, I plan to open-source the entire engine. Right now I’m busy with the other things, I will probably do it in a month once my other work has quieted down. I’m glad you like this, I will post an announcement on this forum when I do release it.

1 Like

A note on bounding boxes.

I spent a disproportionate amount of time inventing solutions to efficiently track bounding box of the particle cloud. I created a time series database with a super-effcient traversal mechanism that has amazingly low code and data foot print, I wrote an analytical algorithm to estimate volume of the emission cone, I felt pretty good about myself! :sunglasses:

Then I found that my estimation was still lacking, sometimes the box was too large, which caused culling issues, more times than I care to admit the system would produce slightly wrong results which I spent hours debugging. :beetle:

After all that - I reverted to just updating the bounding box the old fashioned way, inside the simulation loop. I have to loop through all the live particles anyway to perform the simulation update - so I figured - hey, let’s just try this. Lo and behold - there was no dreaded performance drop, in fact, simulation time has barely gone up. And now we have exact bounding box at every tick of the simulation.

I feel pretty silly :smiley:

Truth be told - I don’t think that I could have used this solution from the start, internals of the engine have changed so much over the weeks of efforts invested into it that it’s an obvious solution now.

Here you have it, a story and best wishes to you all in this new decade! :christmas_tree:


Little bit of an update. I wanted to add some particle effect into my game for the end-boss, so I figured I’d share :mermaid:
The boss is a mage and he has 6 different “stances”, each stance is tied to one of four elements:






each effect is 2-3 “layers” of sorted particles with different emission volumes/sprites/properties.


Looks awesome, Alex! :star_struck:
I’d be very curious about your soft particle implementation.

btw I can’t help but notice that Earth aura looks sorta “stinky” :eyes: :skunk:

1 Like

Haha, that’s fair. I struggle with representation of “Earth”. As it stands, every “earthy” effect kinda sucks, I guess I’ll keep trying :slight_smile:

I found that a lot of stuff when it comes to particles is about technique, you have some vision, but unless you can come up with a way to break it down into working pieces - it’s just not going to look right. For me, particles still remain one of the tougher areas to handle.

1 Like

@Unsul : Have you released the game engine yet? Would LOVE to use it in my own game! <3

Hey @Aerion, the engine has been released on github, I haven’t updated it for a while, but what’s there is a product of 6 years of work or so.

The documentation is a weak point.

1 Like

I recently decided expand the simulation complexity, added something similar to what unity does. I have broken up the monolithic simulation process into several smaller steps and added some new ones. Each simulation step can be optionally applied to any emitter in the scene with per-emitter parameters.

With this it’s possible to apply gravity to some particles, or curl noise for example. Here’s a little demo.

Currently the simulation part is done in JS, I’m thinking of moving it over to GL side with transform feedback in the future. But for now i’m quite happy with the results as there’s next to zero GC involved so the simulation is quite fast and each step can be further optimized by hand if needed.


soooooooooooo cool!

1 Like

Can you share how to make a good-looking particle effect, and how to edit the trajectory of particles?

Editing particle trajectory is not something you do directly, typically. My particle engine doesn’t even support that. The reason for that is: particles are typically used in large quantities, 10s, 100s or even 1000s of particles at the same time, and to make them look somewhat interesting - you generally want some chaos in there. Animating even 10 particles over, say 10 seconds can be quite a chore, it gets worse for 100 or 1000 particles. So animation is generally handled procedurally, you define some formula for particle motion and engine handles the rest.

My engine offers fairly simple speed+position physics simulation. Particles can be spawned in volumes, there are 3 volumes provides:

  • point
  • box
  • sphere

Emission can be done from inside the volume, or from the surface of the volume.

Particle emitters have a parameter to control how long each particle lives, once a particle dies - it is removed from the screen. This “life” is described as a numeric range, min and max, and whenever a particle is created - it is assigned a random life duration between those two.

As far as it comes to making “good-looking” effects. I can’t help much here, I’m afraid. I don’t consider myself an artist, I learned by imitation mostly and reading tutorials on the internet. So all my knowledge is unstructured, it’s not suitable for teaching. I’m sure there are others here that could provide such an advice though.


a small demo, scene more appropriate to show off curl noise


pr:Can you provide some particle related demos in the project? To be honest, I can understand your particle engine, but I don’t hnow how to use it .:sob:

1 Like