SlideShare ist ein Scribd-Unternehmen logo
1 von 27
GPU Particle System
Wolfgang Engel
Confetti Special Effects Inc., Carlsbad
Paris Master Class
Agenda
• Why GPU Particle System (PS)?
• Difference between a Stateless / State-
preserving PS
• Implementation of a State-preserving PS
Particle System
Particle System
Particle System
Particle System
Why GPU Particles?
• CPU Particles:
– transfer bandwidth of particle data CPU -> GPU ==
bottleneck
– CPU not fast enough
• GPU Particles [Latta]:
– Data is generated on the GPU and kept on the
GPU
minimize CPU <-> GPU interaction
– Challenges: how to play sound ….
Stateless / State-Preserving PS
• Stateless: data computed from birth to death by closed-form
function
p is the computed particle position
p0 is the initial position
v0 is the initial velocity
t is the current time
• Does not store current position or other attributes
-> can hardly react to a change of the environment
• First-gen programmable GPU -> 99% of all particle systems
used in games
• Ideal for small and simple effects without environment
interaction e.g. weapon, splash, sparks of a collision
Stateless / State-Preserving PS
• State-preserving: numerical, iterative
integration method
– Compute particle data every frame by comparing
with the data from the previous frame
• Integral of acceleration over time gives you velocity
• Integral of velocity over time gives you position
– Based on environmental changes or other changes
• More flexible -> Next-Gen
State-Preserving PS
• Agenda
– Particle Data Storage
– Process birth and death
– Update Velocities
– Update Positions
– (Optional) Sort for alpha blending or other
reasons
State-Preserving PS
• Particle Data Storage
• Most important data is position and velocity
• There is also orientation, size, color, opacity
• Stored each in render targets (several values packed up in
16-bit or 32-bit fp render target channels)
-> each texture is conceptually treated as a 1D array;
texture coordinates representing array indices
-> textures are 2D
• Blit into render target
• Data need to be double-buffered because a texture can’t
be read and write to at the same time
State-Preserving PS
• Process birth and death
– Birth and death are handled on the GPU -> no CPU
interaction
– A time variable decides on the death and re-birth
of the particle
– In case of a GPU Particle system there is re-birth
happening -> the particles just can’t remember
their previous life 
– In other words the slot in the texture is re-used
over and over again
State-Preserving PS
• Process birth and death
pos.w += frameTime;
// if the particle exists since more than 4 seconds let it die and re-birth at the same time with some starting values
if (pos.w >= 4.0)
{
// Restart animation
dir.xyz = sprinkleDir;
pos.xyz = float3(0, -235, 0);
pos.w -= 4.0;
}
else
{
// run a cool physics simulation here
}
State-Preserving PS
• Update Velocities
– Several velocity operations possible
– Global forces: gravity, wind
– Local forces (all are based on a fall off with
distance):
• Attraction
• Repulsion
• Velocity dampening / un-dampening
• Collision response
State-Preserving PS
• Update Velocities
• Complex local forces can be mapped with a 2D or 3D
texture containing vector data -> called flow field texture
• Sampled flow vector vflcan be used with Stoke’s law of a
drag force Fflow on a sphere
• Where η is the flow viscosity, r the radius of the sphere (in
our case the particle) and v the velocity vector
State-Preserving PS
• Update Velocities
• All global and local forces are then accumulated into a single force
vector
• Convert force to acceleration -> Newton physics
where
a is the acceleration vector
F the accumulated force
m the particle’s mass
• Velocity is then updated from acceleration with simple Euler
integration
where
v is the current velocity,
v is the previous velocity
∆t the time step
• Update Velocities
pos.w += frameTime;
if (pos.w >= 4.0)
{
// initialization
} else {
// Gravity
// rough approx. of Newton physics
// a = F / m
// here m is 1.0
// Update position ~ Euler integration
// v = vprev + a * deltaTime
dir.y -= 500.0 * frameTime;
// Update position
// collision handling comes here
}
State-Preserving PS
• Update Velocities
– Dampening
• special case of Stoke’s law of drag force on a sphere
– With vflow == 1.0
• Or just
r – distance
e – small epsilon to prevent divide by 0
• Or just
// dampening simplified
dir.xyz -= (dir.xyz * frameTime2 * 0.4f);
– Un-dampening: imitate self-propelled objects like a bee
State-Preserving PS
• Update Velocities
– Collision [Sims]
– Split velocity (relative to collider) into normal vn ad
tagential vt component
vn = (v.n)n
vt = v - vn
n is the normal of the collider == plane normal/normal map
v is the velocity computed so far
vn is the normal component of velocity
vt is the tangential vector
State-Preserving PS
• Update Velocities
– Collision [Sims]
New velocity is then
dynamic friction Îź reduces the tangential component
resilience Є scales the reflected normal component
vn = collisionPlane.xyz * dot(collisionPlane.xyz, velocity.xyz);
vt = velocity.xyz – vn;
velocity.xyz = (1 – u) * vt – e*vn;
State-Preserving PS
• Update Velocities
– Collision [Sims]
– Challenges
• dynamic friction μ might approach zero
-> don’t apply friction slow-down if velocity is smaller
than threshold
State-Preserving PS
• Update Velocities
– Particles caught in the collider
• Calculate distance twice for previous and current frame
• Create line segment
• Figure out the contact point
• Set the new position to the contact point
float4 collisionPlane = collisionPlanes[collisionPlaneIdx];
float startDist = dot(lastPosition.xyz, collisionPlane.xyz) - collisionPlane.w;
float endDist = dot(position.xyz, collisionPlane.xyz) - collisionPlane.w;
…
//
float3 lineSegment = (position - lastPosition);
float frontbackRatio = abs(startDist) / (abs(startDist) + abs(endDist));
float3 contactPoint = lastPosition + (frontbackRatio * lineSegment);
State-Preserving PS
• Update Velocities
– Other collision
• Terrain: height map -> generate normal from height map
• Complex collisions -> cube collision map store depth and normals
in a cube map
State-Preserving PS
• Update Position
– Integral of velocity over time gives you position
-> Euler Integration again for position
if (pos.w >= 4.0){
// Restart animation
dir.xyz = sprinkleDir;
pos.xyz = float3(0, -235, 0);
pos.w -= 4.0;
} else {
// Gravity
dir.y -= 500.0 * frameTime;
// Update position
// p = p + v * deltaTime
pos.xyz += frameTime * dir;
}
State-Preserving PS
• Sorting
– Sort per-particle
• For alpha blending
– Ignore if possible
– Use Order-Independent Transparency
– Sort on the GPU -> expensive see [Latta]
• Any other reason to sort per-particle -> probably not
– Sort per-emitter
• Sort emitters with certain properties like lights, lights
and shadows and render them together
• Sort on the CPU -> send down new index points into
the render targets -> next to free on the GPU
State-Preserving PS
• Alternatives to Euler Integration
– Verlet Integration see [Latta] -> save the velocity
buffer
– Runge Kutta RK4 [Fiedler]
State-Preserving PS
References
• [Latta] Lutz Latta, http://www.2ld.de/
• [Fiedler] Glenn Fiedler
http://gafferongames.com/game-physics/integrat
• [Sims] Sims, Karl; Particle Animation and
Rendering Using Data Parallel Computation, in
SIGGRAPH Proceedings 1990

Weitere ähnliche Inhalte

Was ist angesagt?

Porting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsPorting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsIgor Sfiligoi
 
Recursive Compressed Sensing
Recursive Compressed SensingRecursive Compressed Sensing
Recursive Compressed SensingPantelis Sopasakis
 
Introduction to Date and Time API 4
Introduction to Date and Time API 4Introduction to Date and Time API 4
Introduction to Date and Time API 4Kenji HASUNUMA
 
HMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude ControlHMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude ControlPantelis Sopasakis
 
Distributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUsDistributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUsPantelis Sopasakis
 
Libxc a library of exchange and correlation functionals
Libxc a library of exchange and correlation functionalsLibxc a library of exchange and correlation functionals
Libxc a library of exchange and correlation functionalsABDERRAHMANE REGGAD
 
Chapter 3 Powerpoint - AP
Chapter 3 Powerpoint - APChapter 3 Powerpoint - AP
Chapter 3 Powerpoint - APMrreynon
 
Sloshing-aware MPC for upper stage attitude control
Sloshing-aware MPC for upper stage attitude controlSloshing-aware MPC for upper stage attitude control
Sloshing-aware MPC for upper stage attitude controlPantelis Sopasakis
 
Gossip-based resource allocation for green computing in large clouds
Gossip-based resource allocation for green computing in large cloudsGossip-based resource allocation for green computing in large clouds
Gossip-based resource allocation for green computing in large cloudsRerngvit Yanggratoke
 
Building Structure calculation
Building Structure calculationBuilding Structure calculation
Building Structure calculationJy Chong
 
Fuzzy clustering and merging
Fuzzy clustering and mergingFuzzy clustering and merging
Fuzzy clustering and mergingabc
 
Introduction to Hadron Structure from Lattice QCD
Introduction to Hadron Structure from Lattice QCDIntroduction to Hadron Structure from Lattice QCD
Introduction to Hadron Structure from Lattice QCDChristos Kallidonis
 
Structural Design Calculations of Cement Mill 4
Structural Design Calculations of Cement Mill 4 Structural Design Calculations of Cement Mill 4
Structural Design Calculations of Cement Mill 4 Benedict Banquil
 
TuringSlashPython - Undergraduate Final Year Project
TuringSlashPython - Undergraduate Final Year ProjectTuringSlashPython - Undergraduate Final Year Project
TuringSlashPython - Undergraduate Final Year ProjectAlex Psarras
 

Was ist angesagt? (17)

Porting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUsPorting and optimizing UniFrac for GPUs
Porting and optimizing UniFrac for GPUs
 
Recursive Compressed Sensing
Recursive Compressed SensingRecursive Compressed Sensing
Recursive Compressed Sensing
 
Introduction to Date and Time API 4
Introduction to Date and Time API 4Introduction to Date and Time API 4
Introduction to Date and Time API 4
 
HMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude ControlHMPC for Upper Stage Attitude Control
HMPC for Upper Stage Attitude Control
 
Distributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUsDistributed solution of stochastic optimal control problem on GPUs
Distributed solution of stochastic optimal control problem on GPUs
 
Libxc a library of exchange and correlation functionals
Libxc a library of exchange and correlation functionalsLibxc a library of exchange and correlation functionals
Libxc a library of exchange and correlation functionals
 
Thesis
ThesisThesis
Thesis
 
Chapter 3 Powerpoint - AP
Chapter 3 Powerpoint - APChapter 3 Powerpoint - AP
Chapter 3 Powerpoint - AP
 
Sloshing-aware MPC for upper stage attitude control
Sloshing-aware MPC for upper stage attitude controlSloshing-aware MPC for upper stage attitude control
Sloshing-aware MPC for upper stage attitude control
 
Gossip-based resource allocation for green computing in large clouds
Gossip-based resource allocation for green computing in large cloudsGossip-based resource allocation for green computing in large clouds
Gossip-based resource allocation for green computing in large clouds
 
Building Structure calculation
Building Structure calculationBuilding Structure calculation
Building Structure calculation
 
Fuzzy clustering and merging
Fuzzy clustering and mergingFuzzy clustering and merging
Fuzzy clustering and merging
 
Paralell
ParalellParalell
Paralell
 
Introduction to Hadron Structure from Lattice QCD
Introduction to Hadron Structure from Lattice QCDIntroduction to Hadron Structure from Lattice QCD
Introduction to Hadron Structure from Lattice QCD
 
ISR
ISRISR
ISR
 
Structural Design Calculations of Cement Mill 4
Structural Design Calculations of Cement Mill 4 Structural Design Calculations of Cement Mill 4
Structural Design Calculations of Cement Mill 4
 
TuringSlashPython - Undergraduate Final Year Project
TuringSlashPython - Undergraduate Final Year ProjectTuringSlashPython - Undergraduate Final Year Project
TuringSlashPython - Undergraduate Final Year Project
 

Ähnlich wie Paris Master Class 2011 - 06 Gpu Particle System

Os4
Os4Os4
Os4issbp
 
Game Programming 11 - Game Physics
Game Programming 11 - Game PhysicsGame Programming 11 - Game Physics
Game Programming 11 - Game PhysicsNick Pruehs
 
S4495-plasma-turbulence-sims-gyrokinetic-tokamak-solver
S4495-plasma-turbulence-sims-gyrokinetic-tokamak-solverS4495-plasma-turbulence-sims-gyrokinetic-tokamak-solver
S4495-plasma-turbulence-sims-gyrokinetic-tokamak-solverPraveen Narayanan
 
Reinforcement Learning and Artificial Neural Nets
Reinforcement Learning and Artificial Neural NetsReinforcement Learning and Artificial Neural Nets
Reinforcement Learning and Artificial Neural NetsPierre de Lacaze
 
Implement a modified algorithm PF in a FPGA
Implement a modified algorithm PF in a FPGAImplement a modified algorithm PF in a FPGA
Implement a modified algorithm PF in a FPGABruno MartĂ­nez Bargiela
 
4.3 real time game physics
4.3 real time game physics4.3 real time game physics
4.3 real time game physicsSayed Ahmed
 
Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Nick Pruehs
 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Unity Technologies
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )Ruslan Shevchenko
 
SPU Physics
SPU PhysicsSPU Physics
SPU PhysicsSlide_N
 
OpenSees dynamic_analysis
OpenSees dynamic_analysisOpenSees dynamic_analysis
OpenSees dynamic_analysisDhanaji Chavan
 
Insomniac Physics
Insomniac PhysicsInsomniac Physics
Insomniac PhysicsSlide_N
 
Parallel programming
Parallel programmingParallel programming
Parallel programmingAnshul Sharma
 
Frequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfFrequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfSunil Manjani
 
PlayStation: Cutting Edge Techniques
PlayStation: Cutting Edge TechniquesPlayStation: Cutting Edge Techniques
PlayStation: Cutting Edge TechniquesSlide_N
 
Simple, fast, and scalable torch7 tutorial
Simple, fast, and scalable torch7 tutorialSimple, fast, and scalable torch7 tutorial
Simple, fast, and scalable torch7 tutorialJin-Hwa Kim
 
Particle swarm optimization
Particle swarm optimizationParticle swarm optimization
Particle swarm optimizationHanya Mohammed
 
알고리즘 중심의 머신러닝 가이드 Ch04
알고리즘 중심의 머신러닝 가이드 Ch04알고리즘 중심의 머신러닝 가이드 Ch04
알고리즘 중심의 머신러닝 가이드 Ch04HyeonSeok Choi
 

Ähnlich wie Paris Master Class 2011 - 06 Gpu Particle System (20)

Os4
Os4Os4
Os4
 
Game Programming 11 - Game Physics
Game Programming 11 - Game PhysicsGame Programming 11 - Game Physics
Game Programming 11 - Game Physics
 
S4495-plasma-turbulence-sims-gyrokinetic-tokamak-solver
S4495-plasma-turbulence-sims-gyrokinetic-tokamak-solverS4495-plasma-turbulence-sims-gyrokinetic-tokamak-solver
S4495-plasma-turbulence-sims-gyrokinetic-tokamak-solver
 
Reinforcement Learning and Artificial Neural Nets
Reinforcement Learning and Artificial Neural NetsReinforcement Learning and Artificial Neural Nets
Reinforcement Learning and Artificial Neural Nets
 
Implement a modified algorithm PF in a FPGA
Implement a modified algorithm PF in a FPGAImplement a modified algorithm PF in a FPGA
Implement a modified algorithm PF in a FPGA
 
4.3 real time game physics
4.3 real time game physics4.3 real time game physics
4.3 real time game physics
 
Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3Developing a Multiplayer RTS with the Unreal Engine 3
Developing a Multiplayer RTS with the Unreal Engine 3
 
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019Building a turn-based game prototype using ECS - Unite Copenhagen 2019
Building a turn-based game prototype using ECS - Unite Copenhagen 2019
 
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
Papers We Love / Kyiv :  PAXOS (and little about other consensuses )Papers We Love / Kyiv :  PAXOS (and little about other consensuses )
Papers We Love / Kyiv : PAXOS (and little about other consensuses )
 
SPU Physics
SPU PhysicsSPU Physics
SPU Physics
 
OpenSees dynamic_analysis
OpenSees dynamic_analysisOpenSees dynamic_analysis
OpenSees dynamic_analysis
 
Insomniac Physics
Insomniac PhysicsInsomniac Physics
Insomniac Physics
 
Me314 week 06-07-Time Response
Me314 week 06-07-Time ResponseMe314 week 06-07-Time Response
Me314 week 06-07-Time Response
 
Parallel programming
Parallel programmingParallel programming
Parallel programming
 
Frequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdfFrequency Response with MATLAB Examples.pdf
Frequency Response with MATLAB Examples.pdf
 
PlayStation: Cutting Edge Techniques
PlayStation: Cutting Edge TechniquesPlayStation: Cutting Edge Techniques
PlayStation: Cutting Edge Techniques
 
Simple, fast, and scalable torch7 tutorial
Simple, fast, and scalable torch7 tutorialSimple, fast, and scalable torch7 tutorial
Simple, fast, and scalable torch7 tutorial
 
Integration schemes in Molecular Dynamics
Integration schemes in Molecular DynamicsIntegration schemes in Molecular Dynamics
Integration schemes in Molecular Dynamics
 
Particle swarm optimization
Particle swarm optimizationParticle swarm optimization
Particle swarm optimization
 
알고리즘 중심의 머신러닝 가이드 Ch04
알고리즘 중심의 머신러닝 가이드 Ch04알고리즘 중심의 머신러닝 가이드 Ch04
알고리즘 중심의 머신러닝 가이드 Ch04
 

Mehr von Wolfgang Engel

A modern Post-Processing Pipeline
A modern Post-Processing PipelineA modern Post-Processing Pipeline
A modern Post-Processing PipelineWolfgang Engel
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility bufferWolfgang Engel
 
Light and Shadows
Light and ShadowsLight and Shadows
Light and ShadowsWolfgang Engel
 
Paris Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global IlluminationParis Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global IlluminationWolfgang Engel
 
Paris Master Class 2011 - 05 Post-Processing Pipeline
Paris Master Class 2011 - 05 Post-Processing PipelineParis Master Class 2011 - 05 Post-Processing Pipeline
Paris Master Class 2011 - 05 Post-Processing PipelineWolfgang Engel
 
Paris Master Class 2011 - 04 Shadow Maps
Paris Master Class 2011 - 04 Shadow MapsParis Master Class 2011 - 04 Shadow Maps
Paris Master Class 2011 - 04 Shadow MapsWolfgang Engel
 
Paris Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent TransparencyParis Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent TransparencyWolfgang Engel
 
Paris Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material SystemParis Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material SystemWolfgang Engel
 
Paris Master Class 2011 - 01 Deferred Lighting, MSAA
Paris Master Class 2011 - 01 Deferred Lighting, MSAAParis Master Class 2011 - 01 Deferred Lighting, MSAA
Paris Master Class 2011 - 01 Deferred Lighting, MSAAWolfgang Engel
 
Paris Master Class 2011 - 00 Paris Master Class
Paris Master Class 2011 - 00 Paris Master ClassParis Master Class 2011 - 00 Paris Master Class
Paris Master Class 2011 - 00 Paris Master ClassWolfgang Engel
 
A new Post-Processing Pipeline
A new Post-Processing PipelineA new Post-Processing Pipeline
A new Post-Processing PipelineWolfgang Engel
 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft ShadowsWolfgang Engel
 
Hair in Tomb Raider
Hair in Tomb RaiderHair in Tomb Raider
Hair in Tomb RaiderWolfgang Engel
 

Mehr von Wolfgang Engel (13)

A modern Post-Processing Pipeline
A modern Post-Processing PipelineA modern Post-Processing Pipeline
A modern Post-Processing Pipeline
 
Triangle Visibility buffer
Triangle Visibility bufferTriangle Visibility buffer
Triangle Visibility buffer
 
Light and Shadows
Light and ShadowsLight and Shadows
Light and Shadows
 
Paris Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global IlluminationParis Master Class 2011 - 07 Dynamic Global Illumination
Paris Master Class 2011 - 07 Dynamic Global Illumination
 
Paris Master Class 2011 - 05 Post-Processing Pipeline
Paris Master Class 2011 - 05 Post-Processing PipelineParis Master Class 2011 - 05 Post-Processing Pipeline
Paris Master Class 2011 - 05 Post-Processing Pipeline
 
Paris Master Class 2011 - 04 Shadow Maps
Paris Master Class 2011 - 04 Shadow MapsParis Master Class 2011 - 04 Shadow Maps
Paris Master Class 2011 - 04 Shadow Maps
 
Paris Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent TransparencyParis Master Class 2011 - 03 Order Independent Transparency
Paris Master Class 2011 - 03 Order Independent Transparency
 
Paris Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material SystemParis Master Class 2011 - 02 Screen Space Material System
Paris Master Class 2011 - 02 Screen Space Material System
 
Paris Master Class 2011 - 01 Deferred Lighting, MSAA
Paris Master Class 2011 - 01 Deferred Lighting, MSAAParis Master Class 2011 - 01 Deferred Lighting, MSAA
Paris Master Class 2011 - 01 Deferred Lighting, MSAA
 
Paris Master Class 2011 - 00 Paris Master Class
Paris Master Class 2011 - 00 Paris Master ClassParis Master Class 2011 - 00 Paris Master Class
Paris Master Class 2011 - 00 Paris Master Class
 
A new Post-Processing Pipeline
A new Post-Processing PipelineA new Post-Processing Pipeline
A new Post-Processing Pipeline
 
Massive Point Light Soft Shadows
Massive Point Light Soft ShadowsMassive Point Light Soft Shadows
Massive Point Light Soft Shadows
 
Hair in Tomb Raider
Hair in Tomb RaiderHair in Tomb Raider
Hair in Tomb Raider
 

KĂźrzlich hochgeladen

Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoordharasingh5698
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTbhaskargani46
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptxJIT KUMAR GUPTA
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Standamitlee9823
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.Kamal Acharya
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptNANDHAKUMARA10
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlysanyuktamishra911
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...soginsider
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Bookingdharasingh5698
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startQuintin Balsdon
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXssuser89054b
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringmulugeta48
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Arindam Chakraborty, Ph.D., P.E. (CA, TX)
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfJiananWang21
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VDineshKumar4165
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapRishantSharmaFr
 

KĂźrzlich hochgeladen (20)

Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoorTop Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
Top Rated Call Girls In chittoor 📱 {7001035870} VIP Escorts chittoor
 
Generative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPTGenerative AI or GenAI technology based PPT
Generative AI or GenAI technology based PPT
 
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
COST-EFFETIVE  and Energy Efficient BUILDINGS ptxCOST-EFFETIVE  and Energy Efficient BUILDINGS ptx
COST-EFFETIVE and Energy Efficient BUILDINGS ptx
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night StandCall Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
Call Girls In Bangalore ☎ 7737669865 🥵 Book Your One night Stand
 
Employee leave management system project.
Employee leave management system project.Employee leave management system project.
Employee leave management system project.
 
Block diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.pptBlock diagram reduction techniques in control systems.ppt
Block diagram reduction techniques in control systems.ppt
 
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Palanpur 7001035870 Whatsapp Number, 24/07 Booking
 
Integrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - NeometrixIntegrated Test Rig For HTFE-25 - Neometrix
Integrated Test Rig For HTFE-25 - Neometrix
 
KubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghlyKubeKraft presentation @CloudNativeHooghly
KubeKraft presentation @CloudNativeHooghly
 
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
Hazard Identification (HAZID) vs. Hazard and Operability (HAZOP): A Comparati...
 
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 BookingVIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
VIP Call Girls Ankleshwar 7001035870 Whatsapp Number, 24/07 Booking
 
Design For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the startDesign For Accessibility: Getting it right from the start
Design For Accessibility: Getting it right from the start
 
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
 
chapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineeringchapter 5.pptx: drainage and irrigation engineering
chapter 5.pptx: drainage and irrigation engineering
 
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
Navigating Complexity: The Role of Trusted Partners and VIAS3D in Dassault Sy...
 
data_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdfdata_management_and _data_science_cheat_sheet.pdf
data_management_and _data_science_cheat_sheet.pdf
 
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
(INDIRA) Call Girl Aurangabad Call Now 8617697112 Aurangabad Escorts 24x7
 
Thermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - VThermal Engineering-R & A / C - unit - V
Thermal Engineering-R & A / C - unit - V
 
Unleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leapUnleashing the Power of the SORA AI lastest leap
Unleashing the Power of the SORA AI lastest leap
 

Paris Master Class 2011 - 06 Gpu Particle System

  • 1. GPU Particle System Wolfgang Engel Confetti Special Effects Inc., Carlsbad Paris Master Class
  • 2. Agenda • Why GPU Particle System (PS)? • Difference between a Stateless / State- preserving PS • Implementation of a State-preserving PS
  • 7. Why GPU Particles? • CPU Particles: – transfer bandwidth of particle data CPU -> GPU == bottleneck – CPU not fast enough • GPU Particles [Latta]: – Data is generated on the GPU and kept on the GPU minimize CPU <-> GPU interaction – Challenges: how to play sound ….
  • 8. Stateless / State-Preserving PS • Stateless: data computed from birth to death by closed-form function p is the computed particle position p0 is the initial position v0 is the initial velocity t is the current time • Does not store current position or other attributes -> can hardly react to a change of the environment • First-gen programmable GPU -> 99% of all particle systems used in games • Ideal for small and simple effects without environment interaction e.g. weapon, splash, sparks of a collision
  • 9. Stateless / State-Preserving PS • State-preserving: numerical, iterative integration method – Compute particle data every frame by comparing with the data from the previous frame • Integral of acceleration over time gives you velocity • Integral of velocity over time gives you position – Based on environmental changes or other changes • More flexible -> Next-Gen
  • 10. State-Preserving PS • Agenda – Particle Data Storage – Process birth and death – Update Velocities – Update Positions – (Optional) Sort for alpha blending or other reasons
  • 11. State-Preserving PS • Particle Data Storage • Most important data is position and velocity • There is also orientation, size, color, opacity • Stored each in render targets (several values packed up in 16-bit or 32-bit fp render target channels) -> each texture is conceptually treated as a 1D array; texture coordinates representing array indices -> textures are 2D • Blit into render target • Data need to be double-buffered because a texture can’t be read and write to at the same time
  • 12. State-Preserving PS • Process birth and death – Birth and death are handled on the GPU -> no CPU interaction – A time variable decides on the death and re-birth of the particle – In case of a GPU Particle system there is re-birth happening -> the particles just can’t remember their previous life  – In other words the slot in the texture is re-used over and over again
  • 13. State-Preserving PS • Process birth and death pos.w += frameTime; // if the particle exists since more than 4 seconds let it die and re-birth at the same time with some starting values if (pos.w >= 4.0) { // Restart animation dir.xyz = sprinkleDir; pos.xyz = float3(0, -235, 0); pos.w -= 4.0; } else { // run a cool physics simulation here }
  • 14. State-Preserving PS • Update Velocities – Several velocity operations possible – Global forces: gravity, wind – Local forces (all are based on a fall off with distance): • Attraction • Repulsion • Velocity dampening / un-dampening • Collision response
  • 15. State-Preserving PS • Update Velocities • Complex local forces can be mapped with a 2D or 3D texture containing vector data -> called flow field texture • Sampled flow vector vflcan be used with Stoke’s law of a drag force Fflow on a sphere • Where Ρ is the flow viscosity, r the radius of the sphere (in our case the particle) and v the velocity vector
  • 16. State-Preserving PS • Update Velocities • All global and local forces are then accumulated into a single force vector • Convert force to acceleration -> Newton physics where a is the acceleration vector F the accumulated force m the particle’s mass • Velocity is then updated from acceleration with simple Euler integration where v is the current velocity, v is the previous velocity ∆t the time step
  • 17. • Update Velocities pos.w += frameTime; if (pos.w >= 4.0) { // initialization } else { // Gravity // rough approx. of Newton physics // a = F / m // here m is 1.0 // Update position ~ Euler integration // v = vprev + a * deltaTime dir.y -= 500.0 * frameTime; // Update position // collision handling comes here } State-Preserving PS
  • 18. • Update Velocities – Dampening • special case of Stoke’s law of drag force on a sphere – With vflow == 1.0 • Or just r – distance e – small epsilon to prevent divide by 0 • Or just // dampening simplified dir.xyz -= (dir.xyz * frameTime2 * 0.4f); – Un-dampening: imitate self-propelled objects like a bee State-Preserving PS
  • 19. • Update Velocities – Collision [Sims] – Split velocity (relative to collider) into normal vn ad tagential vt component vn = (v.n)n vt = v - vn n is the normal of the collider == plane normal/normal map v is the velocity computed so far vn is the normal component of velocity vt is the tangential vector State-Preserving PS
  • 20. • Update Velocities – Collision [Sims] New velocity is then dynamic friction Îź reduces the tangential component resilience Є scales the reflected normal component vn = collisionPlane.xyz * dot(collisionPlane.xyz, velocity.xyz); vt = velocity.xyz – vn; velocity.xyz = (1 – u) * vt – e*vn; State-Preserving PS
  • 21. • Update Velocities – Collision [Sims] – Challenges • dynamic friction Îź might approach zero -> don’t apply friction slow-down if velocity is smaller than threshold State-Preserving PS
  • 22. • Update Velocities – Particles caught in the collider • Calculate distance twice for previous and current frame • Create line segment • Figure out the contact point • Set the new position to the contact point float4 collisionPlane = collisionPlanes[collisionPlaneIdx]; float startDist = dot(lastPosition.xyz, collisionPlane.xyz) - collisionPlane.w; float endDist = dot(position.xyz, collisionPlane.xyz) - collisionPlane.w; … // float3 lineSegment = (position - lastPosition); float frontbackRatio = abs(startDist) / (abs(startDist) + abs(endDist)); float3 contactPoint = lastPosition + (frontbackRatio * lineSegment); State-Preserving PS
  • 23. • Update Velocities – Other collision • Terrain: height map -> generate normal from height map • Complex collisions -> cube collision map store depth and normals in a cube map State-Preserving PS
  • 24. • Update Position – Integral of velocity over time gives you position -> Euler Integration again for position if (pos.w >= 4.0){ // Restart animation dir.xyz = sprinkleDir; pos.xyz = float3(0, -235, 0); pos.w -= 4.0; } else { // Gravity dir.y -= 500.0 * frameTime; // Update position // p = p + v * deltaTime pos.xyz += frameTime * dir; } State-Preserving PS
  • 25. • Sorting – Sort per-particle • For alpha blending – Ignore if possible – Use Order-Independent Transparency – Sort on the GPU -> expensive see [Latta] • Any other reason to sort per-particle -> probably not – Sort per-emitter • Sort emitters with certain properties like lights, lights and shadows and render them together • Sort on the CPU -> send down new index points into the render targets -> next to free on the GPU State-Preserving PS
  • 26. • Alternatives to Euler Integration – Verlet Integration see [Latta] -> save the velocity buffer – Runge Kutta RK4 [Fiedler] State-Preserving PS
  • 27. References • [Latta] Lutz Latta, http://www.2ld.de/ • [Fiedler] Glenn Fiedler http://gafferongames.com/game-physics/integrat • [Sims] Sims, Karl; Particle Animation and Rendering Using Data Parallel Computation, in SIGGRAPH Proceedings 1990

Hinweis der Redaktion

  1. Iterative – step-by-step Integration – art of finding integrals An Integral is the limit of a series of sums.The usual example is the area under a curve drawn on a graph.You could fit a collection of rectangles under the curve and sum their area. But if you use smaller rectangles you get slightly greater area, as rectangles fit in the gaps.An integral is the result you would get if you added the area of infinitely small rectangles under the curve. Integration is the reverse of Differentiation.Differentiation finds the rate of something.Integration can also be thought of as a running sum:Another common example is position, velocity, and acceleration.Differentiation of your position with respect to time gives your rate of movement = velocity.Differentation of your velocity with respect to time gives you rate of velocity change = acceleration.The integral of acceleration over time gives you velocity.The integral of velocity over time gives you position.Some integrals can be worked out symbolically, others are calculated numerically.Some integrals &amp;quot;cannot be done&amp;quot; symbolically. That is, you can&amp;apos;t do them without simply cheating and saying the answer is another integral.An example is x^x. A common one to do with statistics and probability that &amp;quot;can&amp;apos;t be done&amp;quot; over arbitrary limits is e^(x^2).
  2. Repulsion – rueckstoss
  3. Vector subtraction: Subtraction of two vectors can be geometrically defined as follows: to subtract b from a, place the end points of a and b at the same point, and then draw an arrow from the tip of b to the tip of a. 
  4. Repulsion – rueckstoss
  5. Repulsion – rueckstoss
  6. Repulsion – rueckstoss
  7. Repulsion – rueckstoss
  8. Repulsion – rueckstoss
  9. Repulsion – rueckstoss