Apr 16, 2009
Smoke effects using Alchemy Particle System
I've been experimenting with adding effects to Particle Systems API, which I ported using Alchemy, and came up with some interesting smoke visuals. The effect was achieved by applying blur and displacement map filters on the AS side, which leaves a lot to be desired in regards to performance, but my goal was to showcase the potential of the particle emitter. I plan on moving those operations to C++, perhaps using David Lenaerts Alchemy displacement map technique, once I figure out how I want to architect the effects layer for release (yes, I am planning on releasing the source).
I used a fairly standard displacement map for smoke dissipation:

The Gas Spray demo features a single emitter moving side to side and a central gravitational point that pulls particles around. It's not a very realistic smoke behavior, but generates some unusual shapes. For anyone familiar with Particle Systems, here's the code:
-
static pVec jet(-4, 0, -2.4);
-
static pVec djet = pRandVec() * 0.08;
-
-
jet += djet;
-
-
if(jet.x()> 10 || jet.x() <-10) djet.x() = -djet.x();
-
if(jet.y()> 10 || jet.y() <-10) djet.y() = -djet.y();
-
if(jet.z()> 10 || jet.z() <-10) djet.z() = -djet.z();
-
-
const int LifeTime = 500;
-
-
pVec tjet = Abs(jet) * 0.1 + pVec(0.4, 0.4, 0.4);
-
P.Color(PDSphere(tjet, 0.1));
-
P.Velocity(PDBlob(pVec(0.02, -0.2, 0), 0.015));
-
P.Size(1.0);
-
P.StartingAge(0);
-
-
P.Source(maxParticles / LifeTime, PDPoint(jet));
-
P.OrbitPoint(pVec(.5, .5, .5), 0.1, 3.5);
-
P.Damping(pVec(1, 0.994, 0.994));
-
P.Move(true, false);
-
P.Sink(false, PDSphere(pVec(0, 0, 0), 15));
-
P.KillOld(LifeTime);
The Dust Cloud demo features a plane of particles dispersing upwards slowly. The view is looking at the plane directly from the side.





Awesome work, man! I’m loving the grainy look which makes it look more real. Oh, and just a note: the way I did it wasn’t with a displacement map but a self-advecting velocity field. In 3D, it might be pretty heavy, although I think you can use smaller grid sizes in combination with particles. You’ll need to find a way to make the particles impact the velocity field realistically, which might be a bit tricky (but would look awesome)
If you’re interested, check out the works of Jos Stam and Ron Fedkiw – their articles are a goldmine on information!
Good tips, thanks David.
You’re unstoppable, keep it up!
Cool stuff, your examples had push me to study A LOT.
Thanx for your time!
Hmm, I’m getting a runtime error on the demos…
RangeError: Error #1506: The specified range is invalid.
at cmodule.particle_as3::FSM__start/work()
at cmodule.particle_as3::CRunner/work()
at cmodule.particle_as3::CLibInit/init()
at particleas3/init()[/Projects/personal/particleas3/src/particleas3.as:82]
at particleas3()[/Projects/personal/particleas3/src/particleas3.as:54]
Using Mac os x, safari 4, flash player 10 (debug)
Interesting, I haven’t encountered that problem. It’s failing on the Alchemy initialization, which leads me to think that it’s a problem with your player. It’s working fine for me with osx debug player 10,0,12,36.
Mr. Peter, i was looking to ask u something, theres a way to add this particle system into a 3d engine like Pv3d or away3d, cause to be honest, flint is like a little not-uptaded. I mean any clue to develop this parser?
Fabulous! ALice