Upload
others
View
14
Download
0
Embed Size (px)
Citation preview
GPU ParticlesJason Lubken
1
ParticlesNvidia CUDA SDK
2
ParticlesNvidia CUDA SDK
3
SPHSmoothed Particle Hydrodynamics
Nvidia PhysX SDK
4
SPHSmoothed Particle Hydrodynamics
Nvidia PhysX SDK
5
Advection, Wind Fields& Weather Effects
GPU RainfallPierre Rousseau, Vincent Jolivet, Djamchild Ghazanfarpour 2008
6
Problem
Problem: CPU - GPU communication is too slow for particles
Move everything to the GPU
Problem: Manage computation & storage for potentially O(n2) particle interactions
Optimize & tune
7
Papers
UberFlow: A GPU-Based Particle Engine
Peter Kipfer, Mark Segal, Rüdiger Westermann
Fast N-Body Simulation with CUDA
Lars Nyland, Mark Harris, Jan Prins
8
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
9
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
10
Particle Creation
Encode particle properties in one or more textures
Position (RGB)
Creation time (A)
Velocity (RGB)
Type (A)
Cycle particle regeneration using modulo
11
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
12
Particle Movement:Euler Integration
Iterative
Storage:
Velocity × 2
Position × 2
Update:
v = v’ + a ⋅ ∆t
p = p’ + v ⋅ ∆t
13
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
14
Sorting for Depth
Assign an id to each particle
Compute distance to viewer
Bitonic sort on distance --retain id--
Move position & velocity storage
15
Assigning Ids
Problem: After sorting, find a particle’s original location in a large texture using only a single float id
Distance between consecutive float values is not constant
Millions of particles > 65,536 particles
One bit of exponent is not enough
Precompute the texture of unique ids on the CPU
16
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
17
Adding Sorting Keys
Problem: Resolve collisions without O(n2) comparisons
Construct spacial keys
Like: x/g2 + y/g + z
First use aligned cells
Then use staggered cells
Resolve collisions
18
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
19
UberFlow
Rotation & rotational velocity
Particle types
Surface normal
Color
Shape
Wind field
20
UberFlow
21
UberFlow
22
Papers
UberFlow: A GPU-Based Particle Engine
Peter Kipfer, Mark Segal, Rüdiger Westermann
Fast N-Body Simulation with CUDA
Lars Nyland, Mark Harris, Jan Prins
23
N-Body Simulation
All particles effect one another directly
Brute force without spacial partitioning: O(n2)
Simplification using far-field effects possible
No collision detection
Integration problems with close proximity & high force
Eplison check & different integrator used
24
Force Computation
fij = G ( (mi mj) / |rij|2 ) ⋅ ( rij / |rij| )
mi & mj are mass
r is distance between particle i and particle j
G is gravitational constant
First term is force
Second term is direction
25
Force Optimization
CPU does half the computation
Leapfrog-Vertlet integration
Smoother than Euler integration
Particle positions & acceleration needed --no velocity texture lookup--
Remove mi from computation
Work to overcome integration problems at close proximity also removes fii
26
Summation Optimization
Tile computation of gravitational force
Loop unrolling 32 body-body interaction
Split rows for small N
27
N-Body Simulation
28
N-Body Simulation
29
Ideas
UberFlow
“Clever” use of ids seems computationally intensive
How do you tune this?
N-Body Simulation
Force splatting to alpha buffer
Particle control from CPU using small texture
30
References
UberFlow: A GPU-Based Particle Engine 2004, Peter Kipfer, Mark Segal, Rüdiger Westermann 2004 http://wwwcg.in.tum.de/Research/Publications/UberFLOW
Fast N-Body SImulation with CUDA, Lars Nyland, Mark Harris, Jan Prins 2008 http://http.developer.nvidia.com/GPUGems3/gpugems3_ch31.html (GPU Gems 3)
Everything About Particle Effects, Lutz Lata 2007 http://www.2ld.de/gdc2007/
Broad Phase Collision Detection with CUDA, Scott Le Grand 2008 http://http.developer.nvidia.com/GPUGems3/gpugems3_ch32.html (GPU Gems 3)
31
Particle Movement
Closed or Parametric Form
Vertlet Integration
Euler Integration
Others
32
Particle Movement:Vertlet Integration
Iterative
Storage:
Position × 3
Update:
p = 2p’ - p’’ + a ⋅ ∆t2
33
Particle Movement: Closed or Parametric Form
Stateless
Storage:
Position x 2
Velocity
Update:
p = po + vot + ½a ⋅ t2
34