Skip to content

Particle System Details

pjcozzi edited this page Feb 17, 2013 · 10 revisions

Particles systems are used for smoke, fire, explosion, sparks, clouds, dust, snow, rain, flowing water, etc. Initially, we are are interested in smoke trails.

Initially simulate on the CPU and render with the BillboardCollection.

Abstractions

  • ParticleSystem
    • has an Emitter
      • has an GenerationShape - Interface for the shape of the emitter. Implementations include:
        • Sphere with a radius
        • Circle in the xy plane with an ejectionAngle allowing cone-like emittance.
        • To grow/shrink the particle system, radius, ejectionAngle, etc. can vary over time.
      • has initial particle conditions for:
        • Acceleration range. Range is always mean and maximum variance.
        • Velocity range.
        • Scale.
        • Material properties.
        • TODO: vary over time.
      • has initial conditions for
        • Particles per second.
        • Total number of particles - so we can allocate a vertex buffer once.
        • Start/stop time. Stop after x number of particles, etc.
    • has many Particle objects, which each have:
      • position, velocity, and acceleration.
      • life - remaining life.
      • scale. Need a collisionRadius too?
      • texture and color, including alpha. Need more general material?
      • TODO: velocity for varying everything? Per particle? Global?
      • TODO: vary over time.
    • has many Force objects - an interface for forces applied to particles. Implementations include:
      • Directional forces - wind, gravity, and drift (e.g., smoke drifts upward).
      • Friction - Don't need this right away.
      • TODO: vary over time, e.g., wind speed up or slow down.
    • has many CollisionResponse objects. Implementations include:
      • BouncePlane, e.g., smoke from a launch vehicle interacting with the ground plane.
    • has many ParticleKiller objects. Implementations include:
      • Life expires.
      • Intensity drops below threshold.
      • Positions goes below WGS84. Positions goes outside of bounding volume, etc.
      • TODO: Could more general ParticleManipulator that can start changing the particle's alpha to fade out, etc.

Still need to think about:

  • Determine coarse bounding volume so it doesn't need to be updated each frame.
  • Update/collide when culled?
  • Time can go backwards!

Ideas for Later

  • More GenerationShape objects.
    • Rectangle in the xy plane with an ejectionAngle.
    • Cartographic extent with an ejectionAngle.
  • Particle rotation and angular velocity.
  • Particle mass.
  • Particle system hierarchies – particle systems of particle systems.

Performance

  • Generate a custom vertex shader to simulate on the GPU, and use custom rendering code for better performance. Try to avoid generate approach that requires VTF and ping-ponging textures.
    • Alternatively, explore web workers.
  • Number of particles created per frame varies based on the screen-space of the particle system.

Rendering

  • Sort back-to-front for alpha blending.
  • Draw lines for sparks and/or anti-aliasing.
  • Particles casting shadows in general, and shadows onto other particles in particular.

Resources