Particle Systems - PowerPoint PPT Presentation

1 / 20
About This Presentation
Title:

Particle Systems

Description:

What is a particle system? One of the original uses was in the movie Star Trek II ... Use texture pair and double buffering to compute new data from previous data ... – PowerPoint PPT presentation

Number of Views:66
Avg rating:3.0/5.0
Slides: 21
Provided by: gjk3
Category:
Tags: particle | systems

less

Transcript and Presenter's Notes

Title: Particle Systems


1
Particle Systems
  • GPU Graphics

2
Sample Particle System
Fire and Smoke
Water
3
What is a particle system?
  • One of the original uses was in the movie Star
    Trek II

William Reeves (implementor)
  • Each Particle Had
  • Position
  • Velocity
  • Color
  • Lifetime
  • Age
  • Shape
  • Size
  • Transparency

Particle system from Star Trek II Wrath of Khan
4
Types of Particle Systems
  • Stateless Particle System
  • A particle data is computed from birth to death
    by a closed form function defined by a set of
    start values and a current time. (does not react
    to dynamic environment)
  • State Preserving Particle System
  • Uses numerical iterative integration methods to
    compute particle data from previous values and
    changing environmental descriptions.

5
Stateless Particle Systems on GPU
  • Stateless Simulation Computed particle data by
    closed form functions
  • No reaction on dynamically changing environment!
  • No Storage of varying data (sim. in vertex prog)

Particle Birth
Rendering
Upload time of birth initial Values to dynamic
vertex buffer
Set global function parameter as vertex program
constants
Render point sprites/triangles/quads With
particle system vertex program
6
Particle Life Cycle
  • Generation Particles are generated randomly
    within a predetermined location
  • Particle Dynamics The attributes of a particle
    may vary over time. Based upon equations
    depending on attribute.
  • Extinction
  • Age Time the particle has been alive
  • Lifetime Maximum amount of time the particle
    can live.
  • Premature Extinction
  • Running out of bounds
  • Hitting an object (ground)
  • Attribute reaches a threshold (particle becomes
    transparent)

7
Rendering
  • Rendered as a graphics primitive (blob)
  • Particles that map to the same pixels are
    additive
  • Sum the colors together
  • No hidden surface removal
  • Motion blur is rendered by streaking based on the
    particles position and velocity

8
Issues with Particle Systems on the CPU
  • CPU based particle systems are limited to about
    10,000 particles per frame in most game
    applications
  • Limiting Factor is CPU-GPU communication
  • PCI Express transfer rate is about 3 gigabytes/sec

9
State Preserving Algorithm
  • Rendering Passes
  • Process Birth and Deaths
  • Update Velocities
  • Update Positions
  • Sort Particles (optional, takes multiple passes)
  • Transfer particle positions from pixel to vertex
    memory
  • Render particles

10
Data Storage
  • Two Textures (position and velocity)
  • Each holds an x,y,z component
  • Conceptually a 1d array
  • Stored in a 2d texture (why)
  • Use texture pair and double buffering to compute
    new data from previous data
  • Total number of textures needed ?
  • Storage Types
  • Velocity can be stored using 16bit floats
  • Size, Color, Opacity, etc.
  • Simple attributes, can be added later, usually
    computed using the stateless method

11
Birth and Death
  • Birth allocation of a particle
  • Associate new data with an available index in the
    attributes textures
  • Serial process offloaded to CPU
  • Initial particle data determined on CPU also
  • Death deallocation of a particle
  • Must be processed on CPU and GPU
  • CPU frees the index associated with particle
  • GPU extra pass to move any dead particles to
    unseen areas
  • (i.e. infinity, or behind the camera)
  • In practice particles fade out or fall out of
    view
  • (Clean-up rarely needs to be done)

12
Allocation on CPU
Stack
Heap
2
5
2
10
5
30
10
11
30
6
15
15
26
19
12
26
33
11
19
Optimize heap to always return smallest available
index
12
6
33
Why?
Better!
Easier!
13
Update Velocities
  • Velocity Operations
  • Global Forces
  • Wind
  • Gravity
  • Local Forces
  • Attraction
  • Repulsion
  • Velocity Damping
  • Collision Detection

F S f0 ... fn F ma a F/m If m 1 F a
14
Local Force Flow Field
  • Stokes Law of drag force on a sphere
  • Fd 6??r(v-vfl)
  • ? viscosity
  • r radius of sphere
  • C 6??r (constant)
  • v particle velocity
  • vfl flow velocity

Sample Flow Field
15
Other velocity operations
  • Damping
  • Imitates viscous materials or air resistance
  • Implement by downward scaling velocity
  • Un-damping
  • Self-propelled objects (bee swarms)
  • Implement by upward scaling velocity

16
Collisions
  • Collisions against simple objects
  • Walls
  • Bounding Spheres
  • Collision against complex objects
  • Terrain
  • Complex objects
  • Terrain is usually modeled as a texture-based
    height field

17
Collision Reaction
V
Vn
  • vn (vbc n)vbc
  • vt vbc vn
  • vbc velocity before collision
  • vn normal component of velocity
  • vt tangental component of velocity
  • V (1-µ)vt evn
  • µ dynamic friction (affects tangent velocity)
  • e resilience (affects normal velocity)

Vt
18
Update Positions
  • Euler Integration
  • p pprev v ?t
  • For simple velocity updates
  • Verlet
  • pi1 pi (pi pi-1) a ?t2

19
Sorting for Alpha Blending
  • Odd-even merge sort
  • Good for GPU because it always runs in constant
    time for a given data size
  • Inefficient to check whether sort is done on GPU
  • Guarantees that with each iteration sortedness
    never decreases
  • Full sort can be distributed over 20-50 frames so
    it doesnt slow down system too much (acceptable
    visual errors)
  • Sorting will be covered in lecture 8

20
Questions?
Write a Comment
User Comments (0)
About PowerShow.com