peter nitsch.net

peternitsch.net

Smoke effects using Alchemy Particle System

Gas Spray

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:

Displacement Map

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:

CODE:
  1. static pVec jet(-4, 0, -2.4);
  2. static pVec djet = pRandVec() * 0.08;
  3.  
  4. jet += djet;
  5.  
  6. if(jet.x()> 10 || jet.x() <-10) djet.x() = -djet.x();
  7. if(jet.y()> 10 || jet.y() <-10) djet.y() = -djet.y();
  8. if(jet.z()> 10 || jet.z() <-10) djet.z() = -djet.z();
  9.  
  10. const int LifeTime = 500;
  11.  
  12. pVec tjet = Abs(jet) * 0.1 + pVec(0.4, 0.4, 0.4);
  13. P.Color(PDSphere(tjet, 0.1));
  14. P.Velocity(PDBlob(pVec(0.02, -0.2, 0), 0.015));
  15. P.Size(1.0);
  16. P.StartingAge(0);
  17.  
  18. P.Source(maxParticles / LifeTime, PDPoint(jet));
  19. P.OrbitPoint(pVec(.5, .5, .5), 0.1, 3.5);
  20. P.Damping(pVec(1, 0.994, 0.994));
  21. P.Move(true, false);
  22. P.Sink(false, PDSphere(pVec(0, 0, 0), 15));
  23. 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.

Dust Cloud

Check it out.

Category: Flash

Tagged: , , , , ,

8 Responses

  1. David says:

    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!

  2. Peter Nitsch says:

    Good tips, thanks David.

  3. Mr.doob says:

    You’re unstoppable, keep it up! :D

  4. Daniel says:

    Cool stuff, your examples had push me to study A LOT.

    Thanx for your time!

  5. 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)

  6. Peter Nitsch says:

    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.

  7. desgraci says:

    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?

  8. Alice says:

    Fabulous! ALice

Leave a Reply