Particle Systems(Motion Machines of 2D Objects with Textures)
Matthew K. Bowles
Advanced Computer Graphics
Spring 2004
Particle Systems
• What are particle systems used for?
• Why do we care?
Particle Systems
• Properties:– Evolves (not static).– Procedural (state machines).– Non-deterministic (randomness).– Simple (computationally efficient).– LOD is easy (particle count & size).– Good at complex objects (grass).– Good at amorphous objects (fire).– Good at complex behaviour (explosions).
Particle Systems
• Process:1. Generate new particles with initial
attributes.
2. Kill off particles destined to die.
3. Modify particle attributes.
4. Render remaining particles.
Particle Motion
• State Machines
• Two primary methods for modeling transitions.– Age-
• State transitions due to the temporal plane
– Collision Planes-• State transitions due to the spatial plane
Particle Systems
• Variance:– For all particle attributes we want to provide
some randomness in order to make the system seem more natural.
– Result = Mean + Variance * Rand()
Particle Motion
• Position(x, y, z):– Position = Position + Velocity * Delta_Time
• High variance = Rain & Star field
• Med variance = Fire & Grass
• Low variance = Fireworks & Fountains
– We only draw living particles.
Particle Motion
• Velocity(vx, vy, vz):– Velocity = Velocity – Acceleration *
Delta_Time• High variance = Fireworks & Fountains
• Med variance = Fire & Grass
• Low variance = Rain & Starfield
– The motion is dependent on the relative velocity of each component.
Particle Motion
• Acceleration(ax, ay, az):– Models the sum of the forces on a particle
(typically constant over an entire set of particles). Might change as a function of the current state.
– X and Z often differentiated from Y (i.e., most 3D models maintain Y as the dimension with Earth’s gravity).
Particle Motion
• What about using a direction vector and a velocity magnitude for modeling motion? (d,|m|)– More useful for 3D objects, which must
maintain an orientation.– Particles have no orientation.
Particle Motion
• What about using global accelerations?– Pros – Uses less space and easier to maintain.– Cons – Supports a limited set of particle sets.
Particle Objects
• Idea – – A particle’s shape is essentially the same, no matter
what side of the particle we are looking at.
• Result – – We render a particle as a 2D object.
• Problem – – What about the change in shape due to the camera
view?
Particle Objects
• Bill Boarding– Rendering a 2D object so that the surface of the object is
always perpendicular to the camera view vector.– v0 = vCenter + ((-vRight - vUp) * (particle_size / 2));– v1 = vCenter + (( vRight - vUp) * (particle_size / 2));– v2 = vCenter + (( vRight + vUp) * (particle_size /
2));– v3 = vCenter + ((-vRight + vUp) * (particle_size /
2));– Where vCenter is the location of our particle, and vRight and
vUp are taken from the model-view matrix.
Particle Objects
• Do we have to build a quad for a particle?
• Building the quad and executing the Bill Boarding algorithm takes some overhead processing.
Particle Objects
• Many graphic languages (DirectX and openGL) implement point sprites.
• Point sprites – Build the quad and execute the Bill Boarding
algorithm on the GPU, thus saving CPU processing time.
Particle Textures
• RGBA – – Red, Green, Blue, and Alpha…– What is alpha?
• Alpha used to model opacity (solid objects) and translucence (i.e., glass, water, etc…)
• Lower Alpha Greater Opacity• Higher Alpha Greater Translucence• Is Alpha all that we need?
Particle Textures
• We must enable blending and specify how to blend with a blending factor for source and destination.– Source Incoming Fragment Color (Rs,Gs,Bs,As)
– Destination Stored Pixel Color (Rd,Gd,Bd,Ad)
– Source Blending Factor (Sr, Sg, Sb, Sa)
– Destination Blending Factor (Dr, Dg, Db, Da),
– (RsSr+RdDr, GsSg+GdDg, BsSb+BdDb, AsSa+AdDa)
Particle Textures
• We model the particle as a quad (i.e., a square). However, most particles don’t look like squares… What’s the deal?
• In our particle texture we render some portions invisible. We do this by specifying a clear color and setting the invisible portions of the texture to the same RGB values of the clear color.
Particle Textures
• What about RGB?– We modulate the particle color with the particle
texture so that we can have a dynamic color variance between particles (i.e., we would like to use a limited amount of textures, so we can’t support to many different colors with just texture).
Particle Textures
• Other considerations?– Disable hidden-surface removal. Particles must
blend colors with the objects behind them. Therefore, we must consider all objects that are hidden by particles.
Particle Systems
• Advanced Work– Modeling complex physical phenomena using
real world physics.– Flocking (modeling particles as boids)
• Remember the limitations on motion and shape we stated earlier. We lied. There is a whole other world out there.
Particle System References
• William T. Reeves, Particle Systems - A Technique for Modeling a Class of Fuzzy Objects”, Computer Graphics 17:3 pp. 359-376, 1983 (SIGGRAPH 83).
• www.cs.otago.ac.nz/cosc455/ParticleSystems.pdf • www.opengl.org• www.codesampler.com• www.gametutorials.com• OpenGL Programming Guide (Addison-Wesley
Publishing Company) Second Edition 1997