Presentation is loading. Please wait.

Presentation is loading. Please wait.

Particle Systems GPU Graphics. Sample Particle System Fire and SmokeWater.

Similar presentations


Presentation on theme: "Particle Systems GPU Graphics. Sample Particle System Fire and SmokeWater."— Presentation transcript:

1 Particle Systems GPU Graphics

2 Sample Particle System Fire and SmokeWater

3 What is a particle system? One of the original uses was in the movie Star Trek II William Reeves (implementor) Particle system from Star Trek II: Wrath of Khan Each Particle Had: Position Velocity Color Lifetime Age Shape Size Transparency

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 Upload time of birth & initial Values to dynamic vertex buffer Rendering 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 5 2 30 10 15 26 11 19 12 26 11 19 33 30 6 5 2 15 10 Stack Heap Easier! Better! Optimize heap to always return smallest available index Why? 6 33

13 Update Velocities Velocity Operations  Global Forces Wind Gravity  Local Forces Attraction Repulsion  Velocity Damping  Collision Detection F = Σ 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 F d = 6Πηr(v-v fl ) η = viscosity r = radius of sphere C = 6Πηr (constant) v = particle velocity v fl = 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 n = (v bc * n)v bc v t = v bc – v n v bc = velocity before collision v n = normal component of velocity v t = tangental component of velocity V = (1-μ)v t – εv n μ = dynamic friction (affects tangent velocity) ε = resilience (affects normal velocity) V VtVt VnVn

18 Update Positions  Euler Integration p = p prev + v * Δt For simple velocity updates  Verlet p i+1 = p i + (p i – p i-1 ) + a * Δt 2

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 doesn’t slow down system too much (acceptable visual errors) Sorting will be covered in lecture 8

20 Questions?


Download ppt "Particle Systems GPU Graphics. Sample Particle System Fire and SmokeWater."

Similar presentations


Ads by Google