![Page 1: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/1.jpg)
GPU ParticlesJason Lubken
1
![Page 2: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/2.jpg)
ParticlesNvidia CUDA SDK
2
![Page 3: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/3.jpg)
ParticlesNvidia CUDA SDK
3
![Page 4: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/4.jpg)
SPHSmoothed Particle Hydrodynamics
Nvidia PhysX SDK
4
![Page 5: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/5.jpg)
SPHSmoothed Particle Hydrodynamics
Nvidia PhysX SDK
5
![Page 6: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/6.jpg)
Advection, Wind Fields& Weather Effects
GPU RainfallPierre Rousseau, Vincent Jolivet, Djamchild Ghazanfarpour 2008
6
![Page 7: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/7.jpg)
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
![Page 8: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/8.jpg)
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
![Page 9: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/9.jpg)
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
9
![Page 10: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/10.jpg)
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
10
![Page 11: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/11.jpg)
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
![Page 12: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/12.jpg)
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
12
![Page 13: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/13.jpg)
Particle Movement:Euler Integration
Iterative
Storage:
Velocity × 2
Position × 2
Update:
v = v’ + a ⋅ ∆t
p = p’ + v ⋅ ∆t
13
![Page 14: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/14.jpg)
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
14
![Page 15: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/15.jpg)
Sorting for Depth
Assign an id to each particle
Compute distance to viewer
Bitonic sort on distance --retain id--
Move position & velocity storage
15
![Page 16: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/16.jpg)
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
![Page 17: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/17.jpg)
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
17
![Page 18: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/18.jpg)
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
![Page 19: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/19.jpg)
UberFlow
Particle creation
Particle movement
Particle sorting for depth or particle interaction
(Optional) Particle interaction
Boundary enforcement
Rendering
19
![Page 20: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/20.jpg)
UberFlow
Rotation & rotational velocity
Particle types
Surface normal
Color
Shape
Wind field
20
![Page 21: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/21.jpg)
UberFlow
21
![Page 22: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/22.jpg)
UberFlow
22
![Page 23: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/23.jpg)
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
![Page 24: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/24.jpg)
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
![Page 25: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/25.jpg)
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
![Page 26: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/26.jpg)
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
![Page 27: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/27.jpg)
Summation Optimization
Tile computation of gravitational force
Loop unrolling 32 body-body interaction
Split rows for small N
27
![Page 28: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/28.jpg)
N-Body Simulation
28
![Page 29: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/29.jpg)
N-Body Simulation
29
![Page 30: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/30.jpg)
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
![Page 31: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/31.jpg)
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
![Page 32: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/32.jpg)
Particle Movement
Closed or Parametric Form
Vertlet Integration
Euler Integration
Others
32
![Page 33: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/33.jpg)
Particle Movement:Vertlet Integration
Iterative
Storage:
Position × 3
Update:
p = 2p’ - p’’ + a ⋅ ∆t2
33
![Page 34: GPU Particles - Penn Engineeringcis565/LECTURE2010/Particles GPU.pdfparticles Move everything to the GPU Problem: Manage computation & storage for potentially O(n2) particle interactions](https://reader033.vdocuments.net/reader033/viewer/2022042217/5ec0dfd8b085a7068755a705/html5/thumbnails/34.jpg)
Particle Movement: Closed or Parametric Form
Stateless
Storage:
Position x 2
Velocity
Update:
p = po + vot + ½a ⋅ t2
34