Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity...

35
© 2008 NVIDIA Corporation. Jean Pierre Bordes NVIDIA Corporation Shape of Things to Come: Next-Gen Physics Deep Dive

Transcript of Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity...

Page 1: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Jean Pierre BordesNVIDIA Corporation

Shape of Things to Come: Next-Gen Physics Deep Dive

Page 2: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• PhysX by NVIDIA since March 2008• PhysX on CUDA available: August 2008

Free PhysX on CUDA

GPU PhysX in Games

Page 3: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Physical Characteristics

Scale of Visual Motion

Physical Characteristics

Gaseous Fluid

Liquid Fluid

Deformable Solids

Rigid Solids

Static Solid, Infinite Mass

Smoke/Flames

Water/Oil/Mud

Fabric/ClothingPlants/Pillows/Fat

Leafs/Slivers

SparksGravelSplinters/ShrapnelTrash/RocksFurniture

CharactersVehicles/Machines

Buildings

World Architecture

Page 4: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Physical Characteristics

Number ofComputational

Elements

Opportunity forParallelization

Scale of Visual Motion

Physical Characteristics

Gaseous Fluid

Liquid Fluid

Deformable Solids

Rigid Solids

Static Solid, Infinite Mass

Particle Fluids

Deformables

Particles

Rigid Body Actors

Jointed RB Actors

Static Actors

Smoke/Flames

Water/Oil/Mud

Fabric/ClothingPlants/Pillows/Fat

Leafs/Slivers

SparksGravelSplinters/ShrapnelTrash/RocksFurniture

CharactersVehicles/Machines

Buildings

World Architecture

Page 5: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Presentation Overview

• Introduction• Feature presentations

• Particle systems• Fluids• Deformables

• Parallel PhysX SDK• Conclusion• Demos

Page 6: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Deformablesadding constraints

Fluidsadding SPH forces

Particle Based Features

Particle Systemscolliding with the environment

• Seamless collision with rigid bodies• Algorithmic reuse and consistency• Massively parallel execution on CUDA

enabled GPUs

Page 7: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Ubiquitious in games• Increased realism:

• Universal collision with game environment

• Basis for more advanced features

Particle Systems

Page 8: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Robust Particle Collision

„Edge“ Case(avoid leaking and sticking)

Features• Minimize penetration and artificial energy loss• Handle high velocity collisions• Configurable collision radius• Static over dynamic precedence

Static Precedence

Page 9: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Robust Particle CollisionMixed Approach• Continuous CD: motion ray against shapes• Discrete CD: motion target against shape

p

Continuous Test(multiple shapes)

q

p

p

q

p’old pose

new pose

Continuous Test(moving shape)

Discrete Test

q

Page 10: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

CUDA Implementation

• GPU Workloads(set of particles, set of shapes)

• Particle level parallelism

• Optimization for |shapes| >> |particles|particle-shape pair parallelism for early outs

• Caching of static geometry• Texture cache and shared memory for shapes

t1

t2

t3

t1

t2

t3

Page 11: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Small objects that should collide with the environment• Debris (gravel, shrapnel, dirt bits, etc...) • Shells• Sparks• Leaves, Slivers

• Animate Meshes: Oriented particles that rotate based on collisions

Applications

Page 12: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

GRAW-2

Page 13: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Mathematical descriptions for continuous materials• Lagrangian (particles)• Eulerian (grids)

• Particle vs. Grid based fluid simulation in games• Particles already used in games (easier integration) • Seamless collision with lagrangian game objects• Mass conservation for free

Fluids

Leonhard Euler1707-1783

Joseph-LouisLagrange

1736-1813

Page 14: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Smoothed Particle Hydrodynamics• Particle acceleration given by Navier-Stokes eqn.

• External acceleration (e.g. gravity)• Internal acceleration

• Pressure (pressure field gradient)• Viscosity (smoothed velocity field)

• Particles = sampling points for physical fields• Kernels to reconstruct smooth fields

Page 15: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

2 Passes over particle neighborhood• Density• Force (Pressure, Viscosity)

SPH Algorithm

R

Particle Neighborhood

Densities at Particle Locations

Page 16: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Neighbor finding optimizations• Group particles into cells• Map cells to regular cube (e.g. 16x16x16)• Radix sort particles according to mapping

CUDA Implementation

Page 17: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Neighborhood pass• Particle level parallelization• Texture cache particle access

CUDA Implementation

Page 18: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Dynamic, interactive scenarios• Bursting liquid containers• Flame throwers• Mud puddles• Splashes• …

Applications

Page 19: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

SPH Demo

Page 20: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Deformables= Cloth, Softbody, ...= Particles + Constraints + Meshes

• Specific features• Tearing• Self-collision• Pressure• ... and more

Page 21: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Internal• Stretching (l0)• Bending (ϕ0)• Volume conservation (V)

• External• (Self-)collision• Attachments, adherence, dominance• Custom constraints

Constraintspi2

pi1

pi3

l0

ϕ0

pi4

pi4pi2

pi1

pi3

Vl0

Page 22: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Cloth• Triangle mesh

• Softbody• Tetrahedral mesh• TetraMaker tool

• Simulation vs. graphics mesh

Meshes

Page 23: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Algorithm• Choose vertex p adjacent to

overstretched edge l• Duplicate vertex p → p’• Split mesh perpendicular

to l at vertex p

• Updates• Add particle (p’)• Modify constraints (impacted by p and p’)• Split graphical mesh too!

Tearing

p

p’

p

l

Page 24: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Tearing

Page 25: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• “Perfect” self-collision is tricky & slow• Uncontrollable

external effects• Needs untangling

• Simplified approach• Particle repulsion• Works surprisingly well

... and fast ... in parallel!

Self-collision

Thickness h

Page 26: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Position based dynamics

Simulation Algorithm

1 Update positions p1, …, pnvelocities v1, …, vn

2 Prediction qi = pi + vi·Δt

3 (Self-)collision add constraints based on ray pi → qi

4 Solver for all constraints ci:modify qi1, …, qim to satisfy ci

5 Integration vi = (qi – pi) / Δtpi = qi

6 Damping modify v1, …, vn

Page 27: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Work packet wi = (c1, …, cni, p1, …, pmi, phase)• Each ci is contained in exactly one work packet• All wi contain all particles referenced by c1, …, cni

• For each phase, the partition of particles is disjoint

• Parallel AlgorithmFor phase = 1 to #phases

Process work packets of phase in parallelSync

End for

Parallel Solver

phase 1 2 3

Page 28: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Implementation• Update, (self-)collision, solver kernels• Work on batched instance data• Heavily use shared memory for work packets

CUDA

Page 29: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Nurien

Page 30: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

Parallel PhysX SDK

DeformablesFluids

Particles

Rigid Bodies

PhysX AIRendering ...

Constraints ...

Scenes

...

• Exploits task- and data-parallelismin different layers and modules

Page 31: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Algorithms• Robustness vs. massive parallelism• Generality vs. specialization

• Scheduling• Immediate vs. batched execution• Task- and data-dependencies• Load balancing

• Data management• DMAs, cache hierarchies• Asynchronous access, double-buffering

Parallelization Challenges

Page 32: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

• Particle based features• Broad range of applications• Highly scalable content• Suitable for parallelization

• NVIDIA PhysX SDK• Exploits massive parallelism offered by CUDA• Delivers solution to challenges and complexity• Drives next-gen games and applications• Available now!

Conclusion

Page 33: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

The Great Kulu Demo

Page 34: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

NVIDIA Fluid

Page 35: Shape of Things to Come: Next-Gen Physics Deep Dive · Number of Computational Elements Opportunity for Parallelization Scale of Visual Motion Physical Characteristics Gaseous Fluid

© 2008 NVIDIA Corporation.

The End

Questions?