Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding...

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

Transcript of Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding...

Page 1: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Shape of Things to Come:

Jean Pierre Bordes C

p gNext-Gen Physics Deep Dive

© 2008 NVIDIA Corporation.

NVIDIA Corporation

Page 2: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Free PhysX on CUDAy

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

GPU PhysX in GamesGPU PhysX in Games

© 2008 NVIDIA Corporation.

Page 3: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

PhysX Representation

Physical CharacteristicsPhysical Characteristics

Game World Entities

Number ofComputational

Elements

Gaseous Fluid

Liquid FluidParticle Fluids

Smoke/Flames

Water/Oil/Mud

Opportunity forParallelizationDeformable

SolidsDeformablesFabric/Clothing

Plants/Pillows/Fat

Particles

Leafs/Slivers

SparksG l

Rigid Solids

GravelSplinters/ShrapnelTrash/RocksFurniture

Scale of Visual Motion

Rigid Body Actors

J i t d RB A tCharactersV hi l /M hi Visual Motion

St ti S lid

Jointed RB ActorsVehicles/Machines

Buildings

W ld A hit t

© 2008 NVIDIA Corporation.

Static Solid, Infinite Mass Static Actors

World Architecture

Page 4: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Presentation Overview

I t d ti• Introduction• Feature presentationsp

• Particle systems• Fluids• Fluids• Deformables

• Parallel PhysX SDK• Conclusion• Conclusion• Demos

© 2008 NVIDIA Corporation.

Page 5: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Particle Based Features

Deformablesadding constraints

Fluidsadding SPH forces

Particle Systemscolliding with the environment

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

enabled GPUs© 2008 NVIDIA Corporation.

enabled GPUs

Page 6: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Particle Systemsy

• Ubiquitious in games• Increased realism:Increased realism:

• Universal collision with game environmentenvironment

• Basis for more advanced features

© 2008 NVIDIA Corporation.

Page 7: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Robust Particle CollisionFeatures

Mi i i i d ifi i l l• Minimize penetration and artificial energy loss• Handle high velocity collisions• Configurable collision radius• Static over dynamic precedence

„Edge“ CaseStatic Precedence

© 2008 NVIDIA Corporation.

(avoid leaking and sticking) Static Precedence

Page 8: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Robust Particle CollisionMixed Approach

C i CD i i h• Continuous CD: motion ray against shapes• Discrete CD: motion target against shape

p p

old new

q q

p’old pose

pose

Continuous Test(multiple shapes)

q q

Continuous Test(moving shape)

p

q

© 2008 NVIDIA Corporation.

Discrete Test

Page 9: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

CUDA Implementation p

• GPU Workloadst1

(set of particles, set of shapes)

Particle level parallelism

t1

t2

• Particle level parallelism

• Optimization for |shapes| >> |particles|

t3

particle-shape pair parallelism for early outs

t1

t2

t3

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

© 2008 NVIDIA Corporation.

Page 10: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Applications

• Small objects that should collide with the

pp

• Small objects that should collide with the environment

Debris (gravel shrapnel dirt bits etc ) • Debris (gravel, shrapnel, dirt bits, etc...) • Shells

S k• Sparks• Leaves, Slivers

• Animate Meshes: Oriented particles that rotate based on collisions

© 2008 NVIDIA Corporation.

Page 11: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

GRAW-2

© 2008 NVIDIA Corporation.

Page 12: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Fluids• Mathematical descriptions for continuous materials

• Lagrangian (particles)• 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

Leonhard Euler1707 1783

Joseph-LouisLagrange

1736 1813

© 2008 NVIDIA Corporation.

1707-1783 1736-1813

Page 13: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Smoothed Particle Hydrodynamicsy y• Particle acceleration given by Navier-Stokes eqn.

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

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

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

© 2008 NVIDIA Corporation.

Page 14: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

SPH Algorithm

2 Passes over particle neighborhood

g

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

R

Particle Neighborhood

© 2008 NVIDIA Corporation.

Densities at Particle Locations

Page 15: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

CUDA Implementation • Neighbor finding optimizations

p

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

© 2008 NVIDIA Corporation.

Page 16: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

CUDA Implementation • Neighborhood pass

p

• Particle level parallelization• Texture cache particle access

© 2008 NVIDIA Corporation.

Page 17: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Applications

• Dynamic interactive scenarios

pp

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

© 2008 NVIDIA Corporation.

Page 18: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

SPH Demo

© 2008 NVIDIA Corporation.

Page 19: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

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

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

© 2008 NVIDIA Corporation.

Page 20: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Constraintspi2

l

ϕ0

• Internal• Stretching (l0)

pi1

pi3

l0

pi4

p• Bending (ϕ0)• Volume conservation (V) pi4pi2

pi1

Vl0

• Externalpi3

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

© 2008 NVIDIA Corporation.

Page 21: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Meshes

• Cloth• Triangle mesh

• SoftbodySoftbody• Tetrahedral mesh• TetraMaker toolTetraMaker tool

Si l ti hi h• Simulation vs. graphics mesh

© 2008 NVIDIA Corporation.

Page 22: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Tearingg

l• Algorithm• Choose vertex p adjacent to p

l

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

to l at vertex pp

p’

• Updates

p

• Add particle (p’)• Modify constraints (impacted by p and p’)

© 2008 NVIDIA Corporation.

y ( p y p p )• Split graphical mesh too!

Page 23: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Tearingg

© 2008 NVIDIA Corporation.

Page 24: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Self-collision

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

external effects• Needs untangling

• Simplified approach• Particle repulsion

Thickness h

• Particle repulsion• Works surprisingly well

... and fast ... in parallel!

© 2008 NVIDIA Corporation.

... and fast ... in parallel!

Page 25: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Simulation Algorithmg

• Position based dynamics

1 Update positions p1, …, pnUpdate pos t o s 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 v = (q p ) / Δt5 Integration vi = (qi – pi) / Δtpi = qi

6 Damping modify v1, …, vn

© 2008 NVIDIA Corporation.

1 n

Page 26: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Parallel Solver

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

• For each phase, the partition of particles is disjoint

phase 1 2 3

• Parallel AlgorithmFor phase = 1 to #phasesp p

Process work packets of phase in parallelSync

End for

© 2008 NVIDIA Corporation.

Page 27: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

CUDA

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

© 2008 NVIDIA Corporation.

Page 28: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Nurien

© 2008 NVIDIA Corporation.

Page 29: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Parallel PhysX SDKy

• Exploits task- and data-parallelismp pin different layers and modules

PhysX AIRendering ...

Scenes

DeformablesFluids Rigid Bodies ...

Particles Constraints ...

© 2008 NVIDIA Corporation.

Page 30: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Parallelization Challengesg

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

• Schedulingg• Immediate vs. batched execution• Task- and data-dependenciesp• Load balancing

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

© 2008 NVIDIA Corporation.

• Asynchronous access, double-buffering

Page 31: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

Conclusion

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

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

© 2008 NVIDIA Corporation.

• Available now!

Page 32: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

The Great Kulu Demo

© 2008 NVIDIA Corporation.

Page 33: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

NVIDIA Fluid

© 2008 NVIDIA Corporation.

Page 34: Shape of Things to Come: Next-Gen Physics Deep Dive...Particle Based Features Deformables adding constraints Fluids adding SPH forces Particle Systems colliding with the environment

The End

Q i ?Questions?

© 2008 NVIDIA Corporation.