Title: Writing a Hair Dynamics Solver
1Writing a Hair Dynamics Solver
- Tae-Yong Kim
- Rhythm Hues Studios
- tae_at_rhythm.com
2Hair Simulation Overview
- Understanding the Problem
- State of the Art
- Mass-Spring for Hair
- Length Preservation
- Angle Preservation
- Numerical Integration
- Advanced Issues
3Uniqueness of Hair Dynamics
- Hair does not stretch at all
- But, (long) hair bends quite a lot
- Upon extreme bending, hair becomes stiff
4Uniqueness of Hair Dynamics
- Hair does not stretch at all
- Stiffness Issue in length
- But, (long) hair bends quite a lot
- Preservation of Angular Momentum
- Upon extreme bending, hair becomes stiff
- Stiffness issue in bending
5State of the art
- Rigid joint approach
- Mass-Spring (Clumped Particle Model)
- Continuum approach
6Rigid Joints
- Simulate hair as connected rigid joints
- Developed in robotics field (e.g. Featherstones
algorithm) - Reduced Coordinate Formulation (Hadap2001)
- Generalized Serial Rigid Multi-body chain
(Chang2002)
7Rigid joints state of the art
- Pros
- Natural Model for Hair
- Stiffness in stretch is avoided by formulation
- Cons
- Explicit integration only (Runge Kutta, etc.)
- Another stiffness problem in angles
- Collision response difficult (IK required)
- Hair tip touching shoulder problem
- Fails on stiff hair, fast collision
8Mass Spring
- Simulate hair as connected particle mass
- Early work on hair simulation
- Mass-spring-hinge model
- Explicit integrators
9Mass Spring state of the art
- Pros
- Well understood in other field (e.g. cloth)
- No restriction in collision handling
- More stable integrator available (implicit)
- Cons
- Stiffness issue in explicit integrator
- Angles difficult to deal with in implicit one
10Hair is a non-linear problem
- Rigid Joint (linear in angles)
- Non-linear constraints
- Mass Spring (linear in position)
- Non-linear in angles
11Our choice - Mass Spring
- Friendly for production environment
- Robust Collision Response
- Efficient
- Challenges
- Standard mass spring integrator fails for a
non-linear problem - Implicit integrator helps, but not fully.
12Basic Mass Spring System
xi
xj
13Basic Mass Spring System
xi
xj
L
14Basic Mass Spring System
xi
xj
Fj
15Basic Mass Spring System
xi
xj
Fj
16Basic Mass Spring System
17How large is k ?
18k
?
- Hair does not stretch at all
- k is close to infinity
19k
?
n
- Explicit integrator diverges on
- Large dt (smaller dt? slow!)
- Large k (smaller k? looks bad!)
20k
?
- Implicit integrator adds stability
- Large dt (OK)
- Large k (OK)
21k
?
? implicit integration?
n1
22Implicit integration a closer look
23Implicit integration a closer look
Damping
Filter
- Implicit integrator adds stability thru
- Wider filtering of velocity
- Artificial Damping
24Implicit integration as a filter
Damping
Filter
Velocity Field
25As k becomes larger, Implicit filter widens
Smaller k
larger k
26As K??, implicit filter makes things move together
Smaller k
k??
- Stability gain good for cloth, not quite for hair
- Too large k results in excessive smoothing
- ?Loss of angular momentum
- Too small k results in stretching of hair
27Implicit integration as a damping force
- Artificial damping is automatically added
- Damping term depends on k and dt
- ?Increase in stability, but loss of accuracy
- ?too much damping as k approaches ?
28k
?
? implicit integration?
n1
- Implicit integrator adds stability
- Loss of angular momentum
- Good Jacobian (filter) very important
29k
Is infinity!
- Well, how do we preserve length then?
- ? use non-linear correction
30non-linear post correction
31non-linear post correction
32non-linear post correction
33non-linear post correction
- Post solve correction
- Successive relaxation until convergence
- Guaranteed length preservation
- Cheap simulation of k?infinity
34non-linear post correction
- How to implement?
- Cloth simulation literatures
- Provot 1995 (position only)
- Bridson 2002 (impulse)
- Hair-specific relaxation possible
35non-linear post correction
- Provot1995
- Simulates biphasic spring
- Apply correction until convergence (or time
limited) - Non-linear, Non-dynamic inverse kinematic
procedure
36non-linear post correction
- Bridson2002
- Momentum preserving impulse
- Non-linear Jacobi vs Gauss-Seidel
37k
?
Recap
- Large k not good
- Explicit integrator blows up
- Loss of angular momentum in implicit solvers
38k
?
Recap
- Use post-step relaxation
- Very small k ok
- Explicit integrators ok
39Angle preservation
- Length preservation isnt enough
- Hair tends to go back to original shape
40Angle preservation
41Angle preservation
- Flexion spring?
- Linear spring between distant nodes.
42Flexion spring (x)
- Linear Spring ? Loss of angular momentum
- Ambiguity in direction for angles gt 180?
- Unwanted wrinkles in hair shape
43Angle preservation
- Derivation on angles
- Two angles suffice (no torsion)
- Energy derived from changes in angles
44Angle preservation
?0
F
?
45Angle preservation
- Derivation on angles
- Additional anchor point needed at the root
46Angle preservation
- Derivation on angles
- Full angle required (360 ?)
- Axis generation an issue
47Angle preservation
- Implicit integration used on angles
- Non-linear problem again
- Jacobian treatment needed
48Predictor-corrector scheme
- Implicit integration as a predictor for angles
- Non-linear corrector for length
- Two-pass implicit filtering with non-linear
corrector in the middle of integration - Linearized Implicit integrator augmented with a
non-linear optimizer
49Predictor-corrector scheme
- Implicit Filter (Predictor)
- Implicit Filter (Predictor)
501.First pass-implicit integration
- First implicit solve to get new velocity
512.First pass-implicit integration
- Advance position with the predicted mid-step
velocity
523.Non-linear Correction
- Apply non-linear corrector to get position
(length) right
534.Impulse
- Change velocity due to length preservation
- Velocity may be out of sync after impulse
545.Second implicit integration
- Filters out velocity field
- Velocity field in sync again
55Recap - Simulating Hair with Mass Spring System
- Hair dynamics is a non-linear numerical
integration problem - Standard mass spring integrator fails
- Implicit integrator helps, but not enough.
- Predictor-corrector scheme
56Numerical integration
- Hair system is a banded system
- Block-tridiagonal (3 bands, length only)
- Block-diagonal (5 bands including angles)
- non-iterative, fast solver exists
- blockwise cholesky, LU decomposition
- 10-20x faster than Conjugate Gradient
57Advanced Issues
- Collision handling
- Standard particle-based collision handler works
seamlessly - Flexibility in collision response
- Projection Invariant in implicit integration
(Baraff-Witkin Style) - Direct position alternation (corrector term)
58Advanced Issues
- Hair-hair interaction
- Many ideas from existing simulation literature
such as - Proximity-based spring forces
- Continuous collision
- Rigid body like interaction
- Fluid-like interaction
- .
59Movies and QA
- Hair without bending force
- Hair with bending force
- Non-straight rest shape
- Collision of stiff hair
- Hair hair interaction type I
- Hair hair interaction type II