Introduction to Computer Graphics – Animation (2) – May 26, 2016 Kenshi Takayama
Physically-based deformations 2
Simple example: single mass & spring in 1D • Mass 𝑛 , position 𝑦 , spring coefficient 𝑙 , rest length 𝑚 , gravity : 𝑃 𝑛 𝑒 2 𝑦 Equation of motion 𝑒𝑢 2 = −𝑙 (𝑦 − 𝑚) + 𝑙 = 𝑔 int 𝑦 + 𝑔 ext 𝑚 ext : External force (gravity, collision, user interaction) • 𝑔 𝑛 𝑦(𝑢) int 𝑦 : Internal force (pulling the system back to original) • 𝑔 • Spring’s internal energy (potential): 𝐹 𝑦 ≔ 𝑙 𝑦 − 𝑚 2 2 • Internal force is the opposite of potential gradient: int 𝑦 ≔ − 𝑒𝐹 𝑔 𝑒𝑦 = −𝑙 𝑦 − 𝑚 3
𝑗 2 Mass-spring system in 3D 𝑗 1 𝑚 𝑘 • 𝑂 masses: 𝑗 -th mass 𝑛 𝑗 , position 𝑦 𝑗 ∈ ℝ 3 • 𝑁 springs: 𝑘 -th spring 𝑓 𝑘 = 𝑗 1 , 𝑗 2 • Coefficient 𝑙 𝑘 , rest length 𝑚 𝑘 • System’s potential energy for a state 𝐲 = (𝑦 1 , … , 𝑦 𝑂 ) ∈ ℝ 3𝑂 : 𝑙 𝑘 2 𝐹 𝐲 ≔ 𝑦 𝑗 1 − 𝑦 𝑗 2 − 𝑚 𝑘 2 𝑓 𝑘 = 𝑗 1 ,𝑗 2 • Equation of motion: 𝐍 𝑒 2 𝐲 𝑒𝑢 2 = −𝛂𝐹(𝐲) + 𝐠 ext • 𝐍 ∈ ℝ 3𝑂×3𝑂 : Diagonal matrix made of 𝑛 𝑗 (mass matrix) 4
Continuous elastic model in 2D ( F inite E lement M ethod) Tessellate the domain into triangular mesh • 𝑂 vertices: 𝑗 -th position 𝑦 𝑗 ∈ ℝ 2 • 𝑁 triangles: 𝑘 -th triangle 𝑢 𝑘 = (𝑗 1 , 𝑗 2 , 𝑗 3 ) • Undeformed state: 𝐘 = (𝑌 1 , … , 𝑌 𝑂 ) ∈ ℝ 2𝑂 𝐆 • Deformed state: 𝐲 = 𝑦 1 , … , 𝑦 𝑂 ∈ ℝ 2𝑂 -1 • Deformation gradient: 𝐆 𝑌 𝑗 2 – 𝑌 𝑗 1 𝑌 𝑗 3 – 𝑌 𝑗 1 𝑦 𝑗 2 – 𝑦 𝑗 1 𝑦 𝑗 3 – 𝑦 𝑗 1 𝐆 𝑘 𝐲 ≔ ∈ ℝ 2×2 Linear transformation which maps edges Area of 𝑢 𝑘 • System’s potential: 𝐵 𝑘 2 𝑘 𝐲 ⊺ 𝐆 Green’s strain energy 𝐹 𝐲 ≔ 𝐆 𝑘 𝐲 − 𝐉 ℱ 2 𝑢 𝑘 = 𝑗 1 ,𝑗 2 ,𝑗 3 • Equation of motion: 𝐍 𝑒 2 𝐲 𝑒𝑢 2 = −𝛂𝐹(𝐲) + 𝐠 ext • 𝐍 ∈ ℝ 2𝑂×2𝑂 : Diagonal matrix made of vertices’ Voronoi areas 5
Computing dynamics 𝑒𝐲 • Problem: Given initial value of position 𝐲(𝑢) and velocity 𝐰 𝑢 ≔ 𝑒𝑢 as and 𝐰 0 = 𝐰 0 , 𝐲 0 = 𝐲 0 compute 𝐲(𝑢) and 𝐰(𝑢) for 𝑢 > 0 . (Initial Value Problem) • Simple case of single mass & spring: 𝑛 𝑒 2 𝑦 𝑒𝑢 2 = −𝑙 𝑦 − 𝑚 + analytic solution exists (sine curve) • General problems don’t have analytic solution From state 𝐲 𝑜 , 𝐰 𝑜 at time 𝑢 , compute next state 𝐲 𝑜+1 , 𝐰 𝑜+1 at time 𝑢 + ℎ . (time integration) • ℎ : time step 6
Simplest method: Explicit Euler Discretize acceleration using finite difference: 𝐍 𝐰 𝑜+1 −𝐰 𝑜 = 𝐠 int 𝐲 𝑜 + 𝐠 ext ℎ Update velocity 𝐰 𝑜+1 ← 𝐰 𝑜 + ℎ 𝐍 −1 (𝐠 int (𝐲 𝑜 ) + 𝐠 ext ) Update position 𝐲 𝑜+1 ← 𝐲 𝑜 + ℎ 𝐰 𝑜+1 • Pro: easy to compute • Con: overshooting • With larger time steps, mass can easily go beyond the initial amplitude System energy explodes over time 7
Method to be chosen: Implicit Euler Find 𝐲 𝑜+1 , 𝐰 𝑜+1 such that: 𝐰 𝑜+1 = 𝐰 𝑜 + ℎ 𝐍 −1 𝐠 int 𝐲 𝑜+1 + 𝐠 ext 𝐲 𝑜+1 = 𝐲 𝑜 + ℎ 𝐰 𝑜+1 • Represent 𝐰 𝑜+1 using unknown position 𝐲 𝑜+1 • Pros: can avoid overshoot • Cons: expensive to compute (i.e. solve equation) 8
Inside of Implicit Euler 𝐰 𝑜+1 = 𝐰 𝑜 + ℎ 𝐍 −1 𝐠 int 𝐲 𝑜+1 + 𝐠 ext 𝐲 𝑜+1 = 𝐲 𝑜 + ℎ 𝐰 𝑜+1 = 𝐲 𝑜 + ℎ 𝐰 𝑜 + ℎ 2 𝐍 −1 𝐠 int 𝐲 𝑜+1 + 𝐠 ext = 𝐲 𝑜 + ℎ 𝐰 𝑜 + ℎ 2 𝐍 −1 −𝛂𝐹 𝐲 𝑜+1 + 𝐠 ext Denote unknown 𝐲 𝑜+1 as 𝐳 𝐆 𝐳 ≔ ℎ 2 𝛂𝐹 𝐳 + 𝐍 𝐳 − 𝐍 𝐲 𝑜 + ℎ 𝐰 𝑜 − ℎ 2 𝐠 ext = 𝟏 • Reduce to root-finding problem of function 𝐆: ℝ 3𝑂 ↦ ℝ 3𝑂 Newton’s method: −1 𝐳 𝑗+1 ← 𝐳 𝑗 − 𝑒𝐆 𝐆(𝐳 𝑗 ) 𝑒𝐳 −1 𝐆(𝐳 𝑗 ) = 𝐳 𝑗 − ℎ 2 𝓘 𝐹 𝐳 𝑗 + 𝐍 2 nd derivative of potential 𝐹 (Hessian matrix) • Coefficient matrix of large linear system changes at every iteration high computational cost! 9
Mass-spring model vs continuous model (FEM) • Both: • System potential defined as the sum of deformation energy of small elements • Implicit Euler needed for both • Mass-spring: • Inappropriate for modeling objects occupying continuous 2D/3D domains • Effective for modeling web-/mesh-like materials • FEM: Mass-spring FEM • Higher computational cost in general △ Physical accuracy 〇 • Good domain tessellation Impl. / comput. cost 〇 △ • Complex potential energy • Can handle various (nonlinear) materials 10
P osition- B ased D ynamics 11
PBD: Physics-based animation framework specialized for CG • First PBD papers: • Meshless deformations based on shape matching [Müller et al., SIGGRAPH 2005] • Position Based Dynamics [Müller et al.,VRIPhys 2006] • Basic idea Compute positions making potential zero (goal position), https://www.youtube.com/watch?v=CCIwiC37kks then pull particles toward them • System energy always decreases (never explodes) • Easy to compute perfect for games! • Not physically meaningful computation (e.g. FEM) • OK for CG purposes 12
Case of single mass & spring (no ext. force) Explicit Euler Position-Based Dynamics ℎ 𝑙 𝛽 𝑤 𝑜+1 ← 𝑤 𝑜 + 𝑚 − 𝑦 𝑜 𝑤 𝑜+1 ← 𝑤 𝑜 + ℎ 𝑚 − 𝑦 𝑜 𝑙 𝑛 𝑛 𝑦 𝑜+1 ← 𝑦 𝑜 + ℎ 𝑤 𝑜+1 𝑦 𝑜+1 ← 𝑦 𝑜 + ℎ 𝑤 𝑜+1 𝑃 𝑚 𝑦(𝑢) • 0 ≤ 𝛽 ≤ 1 is “stiffness” parameter unique to PBD • 𝛽 = 0 No update of velocity (spring is infinitely soft) • 𝛽 = 1 Spring is infinitely stiff (?) Energy never explodes in any case • Note: Unit of 𝛽/ℎ is (time) -1 𝛽 has no physical meaning! • Reason why PBD is called non physics-based but geometry-based 13
Case of general deforming shape (no ext. force) Explicit Euler Position-Based Dynamics 𝛽 𝐰 𝑜+1 ← 𝐰 𝑜 − ℎ 𝐍 −1 𝛂𝐹 𝐲 𝑜 𝐰 𝑜+1 ← 𝐰 𝑜 + ℎ 𝐡 𝐲 𝑜 − 𝐲 𝑜 𝐲 𝑜+1 ← 𝐲 𝑜 + ℎ 𝐰 𝑜+1 𝐲 𝑜+1 ← 𝐲 𝑜 + ℎ 𝐰 𝑜+1 • Goal position 𝐡 𝐡(𝐲 𝑜 ) • Rest shape rigidly transformed such that it best matches the 𝐲 0 𝐲 𝑜 current deformed state • (SVD of moment matrix) • Called “Shape Matching” • One technique within the PBD framework • Connectivity info (spring/mesh) not needed meshless 14
Shape Matching per (overlapping) local region • More complex deformations • Acceleration techniques Local regions from voxel lattice Local regions from octree Animating hair using 1D chain structure FastLSM; fast lattice shape matching for robust real-time deformation [Rivers SIGGRAPH07] Fast adaptive shape matching deformations [Steinemann SCA08] 15 Chain Shape Matching for Simulating Complex Hairstyles [Rungjiratananon CGF10]
Extension: Deform rest shapes of local regions Autonomous motion of soft bodies Example-based deformations https://www.youtube.com/watch?v=0AWtQbVBi3s https://www.youtube.com/watch?v=45QjojWiOEc ProcDef; local-to-global deformation for skeleton-free character animation [Ijiri PG09] 16 Real-Time Example-Based Elastic Deformation [Koyama SCA12]
General procedure of PBD • Input: initial position 𝐲 0 & velocity 𝐰 0 • At every frame: prediction 𝐪 = 𝐲 𝑜 + ℎ 𝐰 𝑜 position correction 𝐲 𝑜+1 = modify 𝐪 velocity update 𝐯 = 𝐲 𝑜+1 – 𝐲 𝑜 /ℎ velocity correction 𝐰 𝑜+1 = modify 𝐯 (My understanding is still weak) Position Based Dynamics [Müller et al., VRIPhys 2006] 17 http://www.csee.umbc.edu/csee/research/vangogh/I3D2015/matthias_muller_slides.pdf
Various geometric constraints available in PBD (other than Shape Matching) Twist constraint Stretch constraint Strain constraint Volume constraint Robust Real-Time Deformation of Incompressible Surface Meshes [Diziol SCA11] Density constraint Long Range Attachments - A Method to Simulate Inextensible Clothing in Computer Games [Kim SCA12] Position Based Fluids [Macklin SIGGRAPH13] Position-based Elastic Rods [Umetani SCA14] 18 Position-Based Simulation of Continuous Materials [Bender Comput&Graph14]
Putting everything together: FLEX in PhysX https://www.youtube.com/watch?v=z6dAahLUbZg • SDK released by NVIDIA! 19 Unified Particle Physics for Real-Time Applications [Macklin SIGGRAPH14]
Collisions [Harmon09] • Another tricky issue [Zheng12] [Kaufman08] • Popular methods in PBD: • For each voxel grid, record which particles it contains • Test collisions only among nearby particles • Recent method specialized for PBD Collision detection for deformable objects [Teschner CGF05] Staggered Projections for Frictional Contact in Multibody Systems [Kaufman SIGGRAPHAsia08] Asynchronous Contact Mechanics [Harmon SIGGRAPH09] Energy-based Self-Collision Culling for Arbitrary Mesh Deformations [Zheng SIGGRAPH12] [Muller15] 20 Air Meshes for Robust Collision Handling [Muller SIGGRAPH15]
Recommend
More recommend