Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible...

81
Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019

Transcript of Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible...

Page 1: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Position Based Dynamics A fast yet physically plausible method for deformable body simulation

Tiantian Liu

GAMES Webinar

03/28/2019

Page 2: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Position Based Dynamics A fast yet physically plausible method for deformable body simulation

Tiantian Liu

GAMES Webinar

03/28/2019

Page 3: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Intended Takeaway from this Talk…

• For Rookies…• Basic idea of a deformable body simulation pipeline

• What is Position Based Dynamics (PBD)

• How to implement the basic building blocks of PBD

• For Veterans…• A physically correct understanding of PBD

• Insights and potential improvements of PBD

3

Page 4: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Major References of this Talk

[Müller et al. 2007] [Macklin et al. 2016] [Goldenthal et al. 2007] [Tournier et al. 2015]

4

Page 5: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Computer Graphics (Past and Now)

1986 20175

Page 6: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Deformable Body Simulation

Game Movie/Animation AR/VR6

Page 7: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Deformable Body Simulation

Game Movie/Animation AR/VR7

Page 8: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Deformable Body Simulation

Game Movie/Animation AR/VR8

Page 9: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Rigid Body v.s. Deformable Body

9

Page 10: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Deformable Body Simulation

[Liu et al. 2017]10

Page 11: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Spatial Discretization

11

Page 12: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Representation of a Deformable Body

𝐸 𝒙1, 𝒙2 =1

2𝑘 𝒙1 − 𝒙2 − 𝑙0

2

𝑋1 𝑋2

𝑥1 𝑥2𝑙0

12

Page 13: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Representation of a Deformable Body

Ψ 𝐅(𝒙) = 𝜇 𝛜(𝐅) 𝐹2 +

1

2𝜆𝑡𝑟2(𝛜(𝐅))

13

Deformation Gradient

Strain TensorEnergy Density

Page 14: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Elastic Energy

Rest Pose𝐸 𝒙 = 0

Deformed Pose𝐸 𝒙 > 0

𝐸 𝒙 ↓

14

Page 15: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Temporal Discretization

ℎ𝑥0 𝑥𝑛 𝑥𝑛+1

15

Page 16: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Newton’s 2nd Law of Motion

• 𝑥𝑛+1 = 𝑥𝑛 + t𝑛t𝑛+ℎ 𝑣 𝑡 𝑑𝑡

• 𝑣𝑛+1 = 𝑣𝑛 + t𝑛t𝑛+ℎ𝑀−1 𝑓𝑖𝑛𝑡 𝑥 𝑡 + 𝑓𝑒𝑥𝑡 𝑑𝑡

𝑎(𝑡)

16

Page 17: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Time integration: Implicit Euler

• 𝑥𝑛+1 = 𝑥𝑛 + ℎ𝑣𝑛+1

• 𝑣𝑛+1 = 𝑣𝑛 + ℎ𝑀−1 𝑓𝑖𝑛𝑡 𝑥𝑛+1 + 𝑓𝑒𝑥𝑡

• 𝑥𝑛+1 = 𝑥𝑛 + ℎ𝑣𝑛 + ℎ2𝑀−1𝑓𝑒𝑥𝑡 + ℎ2𝑀−1𝑓𝑖𝑛𝑡(𝑥𝑛+1)

𝑦

17

Page 18: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Variational Implicit Euler

• 𝑥𝑛+1 = 𝑎𝑟𝑔𝑚𝑖𝑛𝑥1

2ℎ2𝑥 − 𝑦 𝑀 + 𝐸(𝑥)

• Pick your favorite optimization tool to solve• Gradient Descent / Newton / Quasi-Newton etc…

inertia elasticity

18

Page 19: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Deformable Body Simulation

[Liu et al. 2017]19

Page 20: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

State-of-the-Art Real-time Simulators

NVIDIA FleX [Video courtesy of NVIDIA]20

Page 21: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

State-of-the-Art Real-time Simulators

Maya nDynamics [Video courtesy of Pixclue Studios]21

Page 22: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Position Based Dynamics

22

Page 23: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Position Based Dynamics

𝑐 𝒙1, 𝒙2 =𝑥1 − 𝑥2

𝑙0− 1

𝑋1 𝑋2

𝑥1 𝑥2𝑙0

Goal: 𝑐 𝒙1, 𝒙2 = 0

23

Page 24: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD: Pipeline

Init:𝑥𝑛+1 = 𝑥𝑛 + ℎ𝑣𝑛 + ℎ2𝑀−1𝑓𝑒𝑥𝑡

Project:Move 𝑥𝑛+1 to satisfy each constraint

24

Page 25: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD: Pipeline (Illustrated version)

𝑥𝑛 𝑥𝑛+1 = 𝑦

Projection

𝑥𝑛+1

25

Page 26: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD: Projection

• Find a projection direction 𝛿𝑥 to:• Satisfy 𝑐 𝑥 + 𝛿𝑥 ≈ 𝑐(𝑥) + 𝛻𝑐 𝑥 𝛿𝑥 = 0

• Conserve linear momentum: Σ𝑚𝑖𝛿𝑥𝑖 = 0

• Conserve angular momentum: Σ𝑚𝑖𝑥𝑖 × 𝛿𝑥𝑖 = 0

26

Page 27: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

• Construct 𝛿𝑥𝑗 for the j-th constraint as:

• 𝛿𝑥𝑗 = −𝑀𝑗−1∇𝑐𝑗

𝑇𝛿𝜆𝑗

• Compute the step size 𝛿𝜆𝑗 using 𝑐𝑗 𝑥 + 𝛻𝑐𝑗𝛿𝑥𝑗 = 0

• 𝛿𝜆𝑗 =𝑐𝑗

𝛻𝑐𝑗𝑀𝑗−1𝛻𝑐𝑗

𝑇

𝛿𝑥𝑗 = −𝑀𝑗−1∇𝑐𝑗

𝑇𝛿𝜆𝑗

PBD: Projection (Cont’d)

27

Page 28: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD Projection Example

𝑥1 𝑥2𝑙0

𝛿𝑥1 𝛿𝑥2

𝑐 =𝑥1 − 𝑥2

𝑙0− 1 ∇𝑐 =

1

𝑙0

𝑥1 − 𝑥2𝑇

𝑥1 − 𝑥2, −

1

𝑙0

𝑥1 − 𝑥2𝑇

𝑥1 − 𝑥2𝐌 =

𝑚1 00 𝑚2

⨂𝐈

𝛿𝜆 =𝑐

∇𝑐𝐌−1𝛻𝑐=

𝑙0

𝑚1−1 +𝑚2

−1 ( 𝑥1 − 𝑥2 − 𝑙0)

28

Page 29: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD Projection Example

𝑥1 𝑥2𝑙0

𝛿𝑥1 𝛿𝑥2

𝛿𝑥1 = −𝑙0

𝑚1−1 +𝑚2

−1 𝑥1 − 𝑥2 − 𝑙0𝑚1

−1

𝑙0

𝑥1 − 𝑥2𝑥1 − 𝑥2

𝛿𝑥2 = −𝑙0

𝑚1−1 +𝑚2

−1 𝑥1 − 𝑥2 − 𝑙0𝑚2

−1

𝑙0−

𝑥1 − 𝑥2𝑥1 − 𝑥2

𝛿𝑥 = −𝐌−1∇𝑐𝑇𝛿𝜆

29

Page 30: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD Projection Example

𝑥1 𝑥2𝑙0

𝛿𝑥1 𝛿𝑥2

𝛿𝑥1 = −𝑚1

−1

𝑚1−1 +𝑚2

−1 𝑥1 − 𝑥2 − 𝑙0𝑥1 − 𝑥2𝑥1 − 𝑥2

𝛿𝑥2 = +𝑚2

−1

𝑚1−1 +𝑚2

−1 𝑥1 − 𝑥2 − 𝑙0𝑥1 − 𝑥2𝑥1 − 𝑥2

30

Page 31: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD: Pipeline

Project:Move 𝑥𝑛+1 to satisfy each constraint

31

Page 32: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Iteration Strategy: Gauss-Seidel v.s. Jacobi

32

Page 33: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Gauss-Seidel

33

Page 34: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Gauss-Seidel

34

Page 35: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Gauss-Seidel

35

Page 36: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Gauss-Seidel

36

Page 37: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Gauss-Seidel

37

Page 38: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Jacobi

38

Page 39: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Gauss-Seidel v.s. Jacobi

• Gauss-Seidel+ Converges faster

- Hard to parallelize

- May break the symmetry

• Jacobi+ Easy to parallelize

- Converges slower

- Less stable

<-- Colored GS [Fratarcangeli et al. 2016]

<-- Symmetric GS

<-- Chebyshev Acceleration [Wang 2015]

<-- Under Relaxation

39

Page 40: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Problems

40[Liu et al. 2013]

Page 41: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Conclusion

• Position Based Dynamics is:• Fast

• Simple to implement

• Stable (for most cases)

• It was also considered:• Non-physically-based (stiffness related to iteration count)

• Hard to control

41

Page 42: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Variational Implicit Euler

• 𝑥𝑛+1 = 𝑎𝑟𝑔𝑚𝑖𝑛𝑥1

2ℎ2𝑥 − 𝑦 𝑀 + 𝐸(𝑥)

•What if 𝐸(𝑥) is (almost) infinitely stiff?

inertia elasticity

42

Page 43: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Constraint-based Variational Implicit Euler

• min𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2𝑠. 𝑡. 𝑐 𝑥 = 0

𝑋1 𝑋2

𝑥1 𝑥2𝑙0

𝑐 𝑥1, 𝑥2 =𝑥1 − 𝑥2

𝑙0− 1 = 0

43

Page 44: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Constraint-based Variational Implicit Euler

• min𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2𝑠. 𝑡. 𝑐 𝑥 = 0

• Optimality Condition:

•𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

• 𝑐 𝑥 = 0

44

Page 45: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Compliant Constraints

• Re-define energy using constraints:

• 𝐸 𝑥 = Σ𝑒𝑖𝜇𝑖𝑐𝑖 𝑥2 =

1

2𝑐 𝑥 𝑇𝐊𝑐(𝑥)

𝐊 = 𝜶−1

Stiffness Matrix Compliance Matrix

=1

2𝑐 𝑥 𝑇𝜶−𝟏𝑐(𝑥)

45

Page 46: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Variational Implicit Euler with compliant constraints

• min𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2 +1

2𝑐 𝑥 𝑇𝜶−𝟏𝑐(𝑥)

• Optimality Condition

•𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜶−1𝑐 𝑥 = 0

• Optimality Condition with 𝜆 = 𝜶−1𝑐 𝑥

•𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

• 𝑐 𝑥 − 𝜶𝜆 = 0

46

Page 47: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Numerical Solutions

• To achieve the exact solution• Newton-Raphson

• To achieve an approximated solution• Step-and-Project [Goldenthal et al. 2007]

• Semi-Implicit Euler [Tournier et al. 2015]

• Position Based Dynamics [Müller et al. 2007, Macklin et al. 2016]

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

47

Page 48: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Newton-Raphson method

• For a given state 𝑥(𝑘) and 𝜆(𝑘)

• Compute Newton-Raphson direction 𝛿𝑥 and 𝛿𝜆 using:

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

𝑀

ℎ2+

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗 𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −

𝑀

ℎ2𝑥(𝑘) − 𝑦 + 𝛻𝑥𝑐

𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

48

Page 49: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Hard Constraints

• 𝜶 = 𝟎

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 = 0

min𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2

𝑠. 𝑡. 𝑐 𝑥 = 0

49

Page 50: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Hard Constraints: Geometric Interpretation

𝑐 𝑥 = 0

𝑦

𝑥∗

min𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2

𝑠. 𝑡. 𝑐 𝑥 = 0

50

Page 51: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Step and Project (SAP) [Goldenthal et al. 2007]

𝑐 𝑥 = 0

𝑦

𝑥∗

𝑐 𝑥 = 0

𝑦𝑥(2)

𝑥(3)

51

Page 52: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Step and Project (SAP) [Goldenthal et al. 2007]

52

𝑐 𝑥 = 0

𝑦

𝑐 𝑥 = 0

𝑦

𝑥𝑘+1 = min𝑥

1

2ℎ2𝑥 − 𝑥(𝑘)

𝑀

2

𝑠. 𝑡. 𝑐 𝑥(𝑘) + 𝛻𝑥𝑐(𝑥𝑘 )(𝑥 − 𝑥(𝑘)) = 0

min𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2

𝑠. 𝑡. 𝑐 𝑥 = 0

Page 53: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

SAP: Update

53

𝑀

ℎ2𝑥 − 𝑥(𝑘) + 𝛻𝑥𝑐 𝑥(𝑘)

𝑇𝜆 = 0

𝑐 𝑥(𝑘) + 𝛻𝑥𝑐(𝑥𝑘 )(𝑥 − 𝑥(𝑘)) = 0

Initialize 𝑥(𝑘+1) and 𝜆(𝑘+1)

with 𝑥(𝑘) and 0

𝑀/ℎ2 𝛻𝑐𝑇

𝛻𝑐 0

𝛿𝑥𝛿𝜆

= −0

𝑐(𝑥 𝑘 )

Schur Complement of 0: −𝛻𝑐 (𝑀/ℎ2)−1𝛻𝑐𝑇

[−𝛻𝑐 𝑀/ℎ2)−1𝛻𝑐𝑇 𝛿𝜆 = −𝑐(𝑥 𝑘 )

Page 54: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

SAP: Update

54

𝑀

ℎ2𝑥 − 𝑥(𝑘) + 𝛻𝑥𝑐 𝑥(𝑘)

𝑇𝜆 = 0

𝑐 𝑥(𝑘) + 𝛻𝑥𝑐(𝑥𝑘 )(𝑥 − 𝑥(𝑘)) = 0

Initialize 𝑥(𝑘+1) and 𝜆(𝑘+1)

with 𝑥(𝑘) and 0

𝑀/ℎ2 𝛻𝑐𝑇

𝛻𝑐 0

𝛿𝑥𝛿𝜆

= −0

𝑐(𝑥 𝑘 )

𝛿𝜆 =1

ℎ2𝛻𝑐 𝑀−1𝛻𝑐𝑇

−1𝑐 𝑥 𝑘

𝛿𝑥 = −ℎ2𝑀−1𝛻𝑐𝑇𝛿𝜆

Page 55: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

SAP: Solution Drifting

55

𝑐 𝑥 = 0

𝑦

𝑥∗

𝑐 𝑥 = 0

𝑦𝑥(2)

𝑥(3)

Page 56: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

SAP vs. the Exact Solution

56

SAP Exact Solution

Page 57: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD vs. SAP

57

• For each constraint j:

• Compute 𝛿𝜆𝑗:𝛿𝜆𝑗 =𝑐𝑗

𝛻𝑐𝑗 𝑀𝑗−1𝛻𝑐𝑗

𝑇

• Compute 𝛿𝑥𝑗: 𝛿𝑥𝑗 = −𝑀𝑗−1𝛻𝑐𝑗

𝑇𝛿𝜆j

• Commit: 𝑥 = 𝑥 + 𝛿𝑥𝑗

• 𝛿𝜆 =1

ℎ2𝛻𝑐 𝑀−1𝛻𝑐𝑇

−1𝑐

• 𝛿𝑥 = −ℎ2𝑀−1𝛻𝑐𝑇𝛿𝜆

• 𝑥 = 𝑥 + 𝛿𝑥

PBD (G-S) SAP

Page 58: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD v.s. SAP: Geometric Interpretation

𝑐 𝑥 = 0

𝑦

𝑥∗

Ground Truth

𝑐 𝑥 = 0

𝑦𝑥(2)

𝑥(3)

SAP

𝑐 𝑥 = 0

𝑦

PBD58

Page 59: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD Problems Visualized

• Solution Drifts

• Non-physically-based

• Hard to Control

𝑐 𝑥 = 0

𝑦

PBD59

Page 60: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD Problems Visualized

• Solution Drifts

• Non-physically-based• Stiffness depends on iteration count

• 𝑦 = 𝑥𝑛 + ℎ𝑣𝑛 + ℎ2𝑀−1𝑓𝑒𝑥𝑡

• Hard to Control 𝑐 𝑥 = 0

𝑦

PBD60

Page 61: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD Problems Visualized

• Solution Drifts

• Non-physically-based

• Hard to Control• min

𝑥

1

2ℎ2𝑥 − 𝑦 𝑀

2

• 𝑠. 𝑡. 𝑐 𝑥 = 0𝑐 𝑥 = 0

𝑦

PBD61

Page 62: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Compliant Constraints

• 𝜶 ! = 𝟎, 𝐸 =1

2𝒄𝑇𝜶−1𝒄

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

62

Page 63: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Compliant Constraints 𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

• 𝜶 ! = 𝟎, 𝐸 =1

2𝒄𝑇𝜶−1𝒄

• Mass Spring System

𝐸 𝒙1, 𝒙2 =1

2𝑘 𝒙1 − 𝒙2 − 𝑙0

2

𝑋1 𝑋2

𝑥1 𝑥2𝑙0

𝑐 𝒙1, 𝒙2 =𝒙1−𝒙2

𝑙0− 1

𝑘 =2𝜇𝐴

𝑙0

𝛼 = 2𝜇𝐴𝑙0−1 = 𝑘𝑙0

2 −1

63

Page 64: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Compliant Constraints 𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

• 𝜶 ! = 𝟎, 𝐸 =1

2𝒄𝑇𝜶−1𝒄

• FEM (3D case)

𝒄 = 𝜖𝑥 𝜖𝑦 𝜖𝑧 𝜖𝑥𝑦 𝜖𝑥𝑧 𝜖𝑦𝑧 𝑇

𝐊 = 𝑉

𝜆 + 2𝜇 𝜆 𝜆𝜆 𝜆 + 2𝜇 𝜆𝜆 𝜆 𝜆 + 2𝜇

𝜇

𝜇

𝜇

𝜶 = 𝐊−1

𝐸 𝐅(𝒙) = 𝑉(𝜇 𝛜 𝐹2 +

1

2𝜆𝑡𝑟2 𝛜 )

𝛜 =

𝜖𝑥 0.5𝜖𝑥𝑦 0.5𝜖𝑥𝑧0.5𝜖𝑥𝑦 𝜖𝑦 0.5𝜖𝑦𝑧0.5𝜖𝑥𝑧 0.5𝜖𝑦𝑧 𝜖𝑧

64

𝐸 =1

2𝒄T𝐊𝒄

Page 65: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Solve Compliant Constraints with Newton

𝑀

ℎ2+

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗 𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −

𝑀

ℎ2𝑥(𝑘) − 𝑦 + ∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

SAP Assumption:

𝑦 → 𝑥 𝑘

∇2𝑐 = 0SAP Initialization:

𝑥 ← 𝑥 𝑘

𝑦𝑥(2)

𝑥(3)

65

Page 66: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Solve Compliant Constraints with SAP

𝑀

ℎ2𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

𝛿𝜆 =1

ℎ2𝛻𝑐 𝑀−1𝛻𝑐𝑇 + ℎ2𝜶

−1𝑐 𝑥 𝑘 − 𝜶𝜆(𝑘)

𝛿𝑥 = −ℎ2𝑀−1𝛻𝑐𝑇𝜆(𝑘+1)𝜆(𝑘+1) = 𝜆(𝑘) + 𝛿𝜆

𝑥(𝑘+1) = 𝑥(𝑘+1) + 𝛿𝑥

66

Page 67: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Solve Compliant Constraints with XPBD[Macklin et al. 2016]𝑀

ℎ2𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

𝐹𝑜𝑟 𝑒𝑎𝑐ℎ 𝑐𝑜𝑛𝑠𝑡𝑟𝑎𝑖𝑛𝑡: 𝑗

Compute: 𝛿𝜆𝑗 =1

ℎ2𝛻𝑐𝑗 𝑀𝑗

−1𝛻𝑐𝑗𝑇 + ℎ2𝜶𝑗

−1𝑐𝑗 𝑥 𝑘 − 𝜶𝑗𝜆𝑗

(𝑘)

Commit: 𝜆𝑗(𝑘+1)

= 𝜆𝑗(𝑘)

+ 𝛿𝜆𝑗

Compute: 𝛿𝑥𝑗 = −ℎ2𝑀𝑗−1𝛻𝑐𝑗

𝑇𝜆𝑗(𝑘+1)

Commit: 𝑥𝑗(𝑘+1)

= 𝑥𝑗(𝑘+1)

+ 𝛿𝑥𝑗67

Page 68: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

PBD v.s. XPBD

• For each constraint j:

• Compute 𝛿𝜆𝑗:𝛿𝜆𝑗 =1

ℎ2

𝑐𝑗

𝛻𝑐𝑗 𝑀𝑗−1𝛻𝑐𝑗

𝑇

• Commit: 𝜆𝑗 = 𝛿𝜆𝑗• Compute 𝛿𝑥𝑗: 𝛿𝑥𝑗 = −ℎ2𝑀𝑗

−1𝛻𝑐𝑗𝑇𝜆𝑗

• Commit: 𝑥 = 𝑥 + 𝛿𝑥𝑗

PBD (G-S) XPBD (G-S)

• For each constraint j:

• Compute 𝛿𝜆𝑗:𝛿𝜆𝑗 =1

ℎ2

𝑐𝑗−𝛼𝑗𝜆𝑗

𝛻𝑐𝑗 𝑀𝑗−1𝛻𝑐𝑗

𝑇+ℎ2𝛼𝑗

• Commit: 𝜆𝑗 = 𝜆𝑗 + 𝛿𝜆𝑗• Compute 𝛿𝑥𝑗: 𝛿𝑥𝑗 = −ℎ2𝑀𝑗

−1𝛻𝑐𝑗𝑇𝜆𝑗

• Commit: 𝑥 = 𝑥 + 𝛿𝑥𝑗

68

Page 69: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

XPBD Result

[Macklin et al. 2016]69

Page 70: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

What is left out?

𝑀

ℎ2+

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗 𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −

𝑀

ℎ2𝑥(𝑘) − 𝑦 + ∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

70

Page 71: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Schur Complement of the Upper-left Block

𝑀

ℎ2+

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗 𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −

𝑀

ℎ2𝑥(𝑘) − 𝑦 + ∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

𝑀

ℎ2+ 𝛻𝑐𝑇𝜶−1𝛻𝑐 +

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗

71

Page 72: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Geometric Stiffness

𝑀

ℎ2+

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗 𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −

𝑀

ℎ2𝑥(𝑘) − 𝑦 + ∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

𝑀

ℎ2+ 𝛻𝑐𝑇𝜶−1𝛻𝑐 +

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗

72

Page 73: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Geometric Stiffness: Example

73

𝑋1 𝑋2

𝑥1 𝑥2𝑙0

𝑐 =𝑥1 − 𝑥2

𝑙0− 1 𝐸 =

1

2𝛼−1𝑐2

𝛻𝑥1,𝑥12 𝐸 = 𝛻𝑐𝑇𝛼−1𝛻𝑐 + (𝛼−1𝑐)𝛻𝑥1,𝑥1

2 𝑐

Geometric Stiffness𝜆

Page 74: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Stable Constrained Dynamics [Tournier et al. 2015]• When to use Geometric Stiffness?

1. Material highly nonlinear

2. Strong stiffness

74

𝑀

ℎ2+

𝑗=1

𝑚

𝜆𝑗(𝑘)𝛻2𝑐𝑗 𝛻𝑐𝑇

𝛻𝑐 −𝜶

𝛿𝑥𝛿𝜆

= −

𝑀

ℎ2𝑥(𝑘) − 𝑦 + ∇𝑐𝑇𝜆(𝑘)

𝑐 𝑥 𝑘 − 𝜶𝜆 𝑘

Page 75: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Conclusion

75

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

constraint #iterations/frame per-iteration cost

[Goldenthal et al. 2007] hard medium medium

[Müller et al. 2007] hard high low

[Tournier et al. 2015] compliant one high

[Macklin et al. 2016] compliant high low

Page 76: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Conclusion: PBD

76

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

constraint #iterations/frame per-iteration cost

[Goldenthal et al. 2007] hard medium medium

[Müller et al. 2007] hard high low

[Tournier et al. 2015] compliant one high

[Macklin et al. 2016] compliant high low

Page 77: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Conclusion: PBD

• The Performance of (X)PBD is…• Similar to one iteration of Jacobi/Gauss-Seidel of SAP

77

Page 78: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Conclusion: SAP

78

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

constraint #iterations/frame per-iteration cost

[Goldenthal et al. 2007] hard medium medium

[Müller et al. 2007] hard high low

[Tournier et al. 2015] compliant one high

[Macklin et al. 2016] compliant high low

Page 79: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Conclusion: Geometric Stiffness

79

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

constraint #iterations/frame per-iteration cost

[Goldenthal et al. 2007] hard medium medium

[Müller et al. 2007] hard high low

[Tournier et al. 2015] compliant one high

[Macklin et al. 2016] compliant high low

Page 80: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Key Takeaway from this Talk

80

• (X)PBD is approximately converging to…

𝑀

ℎ2𝑥 − 𝑦 + 𝛻𝑥𝑐 𝑥 𝑇𝜆 = 0

𝑐 𝑥 − 𝜶𝜆 = 0

𝑐 𝑥 = 0

𝑦

𝑥∗

Ground Truth

𝑐 𝑥 = 0

𝑦

PBD

Page 81: Position Based Dynamicsˆ˜天添.pdf · Position Based Dynamics A fast yet physically plausible method for deformable body simulation Tiantian Liu GAMES Webinar 03/28/2019. Position

Position Based Dynamics A fast yet physically plausible method for deformable body simulation

Tiantian Liu

GAMES Webinar

03/28/2019