Real Time Physics Class Notes
Real Time Physics Class Notes
y
www.matthiasmueller.info/realtimephysics
Cornell University
Schedule
• 8:30 Introduction, Matthias Müller
• 8:45 Deformable Objects, Matthias Müller
• 9:30 Multimodal Physics and User Interaction
Doug James
• 10:15 Break
• 10:30 Fluids, Nils Thuerey
• 11:15 Unified Solver, Jos Stam
• 12:00 Q & A
Real Time Demos
Before Real Time Physics
y
B C tler et al.
B.Cutler al
1999
• Among my literature search:
– D. James et al., ArtDefo, Accurate Real Time
Deformable Objects, Siggraph 1999
– J.Stam, Stable Fluids, Siggraph 1999
• They brought physics brought to life!
• My assignment: make this real-time:
– J. O‘Brien at al., Graphical Modeling and Animation of
Brittle Fracture, Siggraph 1999
ArtDefo
• Boundary element method
• Haptic interaction
Doug
g James
• CV
– 2001: PhD in applied mathematics, University of British Columbia
– 2002: Assistant prof, Carnegie Mellon University
– 2006: Associate prof, Cornell Universtiy
– National Science Foundation CAREER award
• Research interests
– Physically based animation
– Haptic force feedback rendering
– Reduced-order modeling
Stable Fluids
• Semi-Lagrangian advection
• Equation splitting
Jos Stam
• CV
– PhD in computer science, University of Toronto
– Postdoc in Paris and Helsinki
– Senior research scientist at Alias|Wavefront, now Autodesk
– SIGGRAPH Technical Achievement Award
• Research interests
– Natural phenomena
– Physics based simulation
– Rendering and surface modeling
Animation of Brittle Fracture
• Finite elements, separation tensor
• Great results but 5-10 min/frame
J. O‘Brien et al.
Real-Time Fracture of Stiff Materials
• Hybrid rigid body – static FEM
• Not quite as realistic but 30 fps
• Research interests
– Lattice-Boltzmann based fluid simulation
– Real-time height
g field fluid simulation
– Fluid Control
Offline Physics
y
• Applications
– Special effects in movies and commercials
• Typical setup
– Millions of particles / triangles / tetrahedra / grid cells
– Expensive photorealistic rendering
– Impressive high quality results
– Seconds up to hours per frame
• Characteristics
– Predictable,
Predictable re-run
re run possible,
possible no interaction
Real Time Physics
y
• Applications
– Interactive
I t ti systems
t
– Virtual surgery simulators („respectable“, „scientific“)
– Games
G (not
( t so respectable
t bl but
b t true
t i 99%)
in
• Requirements
– Fast, 40-60 fps of which physics only gets a small fraction
– Stable in any possible, non-predictable situation
• Challenge:
– Approach offline results while meeting all requirements!
From Offline to Real Time
• Resolution reduction
– Blobby and coarse look
– Details disappear
• 1d: Ropes,
Ropes hair
• 3d: Fat,
Fat tires,
tires organs
Dimensionality
y
• Rope: chain
– Additional springs for bending
and torsional resistance needed
• Soft
S ft body:
b d tetrahedral
t t h d l mesh
h
Mass Spring
p g Physics
y
• Mass point: mass m, position x, velocity v
v
x m
f -f
• Springs: xi xj
l0
x j − xi ⎡ x j − xi ⎤
f= ⎢ k s ( x j − x i − lo ) + k d ( v j − v i ) ⋅ ⎥
x j − x i ⎢⎣ x j − xi ⎥⎦
• Explicit Euler: vi
t +1
= v i + Δt
t 1
∑ f (x i
t t t t
, vi , x j , v j )
mi j
t +1 t +1
= x i + Δt v i
t
xi
• Stability Δt2f/m
– Overshooting
– Big issue in
real time systems!
Implicit
p Integration
g
• Use values of next time step on the right
1
∑ f (x i , v i , x j , v j )
t +1 t +1 t +1 t +1 t +1
= v i + Δt
t
vi
mi j
t +1 t +1
= x i + Δt v i
t
xi
• Intuitively
– Don‘t extrapolate blindly
– Arrive at a physical configuration
Implicit
p Integration
g Issues
• Unconditionally stable (for any Δt)!
• Have to solve system of equations for velocities
– n mass p
points,, 3n unknowns
– Non linear when the forces are non-linear
in the positions as with springs
– Linearize forces at each time step (Newton-Raphson)
• Reaction lag
• Small ks → squashy system
• Large ks → stiff system, overshooting
Position Based Update
p
• Explicit,
Explicit Verlet related
• If correction done by a solver → semi implicit
Position Correction
• Move vertices out of other objects
• Move vertices such that constraints are satisfied
• Example:
p Particle on circle
prediction
new velocity
correction
Velocity
y Correction
• External forces: vt = ut + Δt·g/m
• Internal damping
• Friction
• Restitution
corrected
velocity
l it
prediction
friction
restitution
collision correction
Internal Distance Constraint
x1 − x 2
Δx2 Δx1 = −
w1
( x1 − x 2 − l0 )
Δx1 l0 w1 + w2 x1 − x 2
m2
x1 − x 2
m1 Δx 2 = +
w2
( x1 − x 2 − l0 )
w1 + w2 x1 − x 2
wi = 1 / mi
• Conservation of momentum
• Stiffness: scale corrections by k ∈ [0..1]
• Easy to tune but effect dependent on time step!
General Internal Constraint
• Define constraint via scalar function:
Cstretch (x1 , x 2 ) = x1 − x 2 − l0
Cvolume (x1 , x 2 , x 3 , x 4 ) = [(x 2 − x1 ) × (x 3 − x1 )]⋅ (x 4 − x1 ) − 6 v0
C=0 ∇C
x2 x1 p0
x0 p2
⎡f 0 ⎤ ⎡p 0 − x 0 ⎤
⎢f ⎥ ⎢p − x ⎥
⎢ 1 ⎥ = K ⎢ 1 1 ⎥, K ∈ R12×12
⎢f 2 ⎥ ⎢p 2 − x 2 ⎥
⎢ ⎥ ⎢ ⎥
⎣f 3 ⎦ ⎣p 3 − x 3 ⎦
x p
linearized non-linear
Corotational Formulation
• Only rotations problematic, translations OK
• Extract rotation: RK(RTp-x)
f R
p-x
RT
RTp-x
p K(RTp-x)
Rotational Part
• Modified force computation
⎡f 0 ⎤ ⎡R 0 0 0 ⎤ ⎛⎜ ⎡R T p 0 ⎤ ⎡x 0 ⎤ ⎞
⎢f ⎥ ⎢ 0 R 0 0 ⎥ ⎜ ⎢ T ⎥ ⎢ ⎥⎟
⎢ 1⎥ = ⎢ ⎥K⎜ ⎢ R p1 ⎥ − ⎢ x1 ⎥ ⎟
⎢f 2 ⎥ ⎢ 0 0 R 0 ⎥ ⎜ ⎢R T p 2 ⎥ ⎢x 2 ⎥ ⎟
⎢ ⎥ ⎢ ⎥ ⎜ ⎢ T ⎥ ⎢ ⎥ ⎟⎟
⎣ 3 ⎦ ⎣ 0 0 0 R⎦ ⎝
f ⎣⎢ R p 3 ⎥⎦ ⎣ x 3 ⎦ ⎠
• Transformation matrix
A = [p1 − p 0 , p 2 − p 0 , p 3 − p 0 ][x1 − x 0 , x 2 − x 0 , x 3 − x 0 ]−1