Tae-Yong Kim - Hair Dynamics

Writing a Hair Dynamics Solver
Tae-Yong Kim
Rhythm & Hues Studios
[email protected]
Hair Simulation Overview







Understanding the Problem
State of the Art
Mass-Spring for Hair
Length Preservation
Angle Preservation
Numerical Integration
Advanced Issues
Uniqueness of Hair Dynamics



Hair does not stretch at all
But, (long) hair bends quite a lot
Upon extreme bending, hair becomes stiff
Uniqueness of Hair Dynamics

Hair does not stretch at all


But, (long) hair bends quite a lot


Stiffness Issue in length
Preservation of Angular Momentum
Upon extreme bending, hair becomes stiff

Stiffness issue in bending
State of the art



Rigid joint approach
Mass-Spring (Clumped Particle Model)
Continuum approach
Rigid Joints


Simulate hair as connected rigid joints
Developed in robotics field (e.g.
Featherstone’s algorithm)


Reduced Coordinate Formulation
(Hadap2001)
Generalized Serial Rigid Multi-body chain
(Chang2002)
Rigid joints – state of the art

Pros



Natural Model for Hair
Stiffness in stretch is avoided by formulation
Cons

Explicit integration only (Runge Kutta, etc.)


Collision response difficult (IK required)


Another stiffness problem in angles
Hair tip touching shoulder problem
Fails on stiff hair, fast collision
Mass Spring


Simulate hair as connected particle mass
Early work on hair simulation


Mass-spring-hinge model
Explicit integrators
Mass 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
Hair is a non-linear problem

Rigid Joint (linear in angles)


Non-linear constraints
Mass Spring (linear in position)

Non-linear in angles
Our 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.
Basic Mass Spring System
xi
xj
Basic Mass Spring System
xi
xj
L
Basic Mass Spring System
xi
xj
Fj
Basic Mass Spring System
xi
xj
Fj
Basic Mass Spring System
How large is
k?
k=


Hair does not stretch at all
k is close to infinity
k=
n

Explicit integrator diverges on


Large dt (smaller dt slow!)
Large k (smaller k looks bad!)
k=
 implicit integration?
n+1

Implicit integrator adds stability


Large dt (OK)
Large k (OK)
k=
n+1
 implicit integration?
Implicit integration – a closer look
Filter
Damping
Implicit integration – a closer look
Filter

Implicit integrator adds stability thru


Wider filtering of velocity
Artificial Damping
Damping
Implicit integration as a filter
Damping
Filter
*
Velocity Field
=
As k becomes larger,
Implicit filter widens
Damping
Filter
Smaller k
*
=
larger k
*
=
As 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
Implicit integration as a damping force
Filter


Damping
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 
k=
 implicit integration?
n+1

Implicit integrator adds stability


Loss of angular momentum
‘Good’ Jacobian (filter) very
important
k Is infinity!
Well, how do we preserve
length then?
 use non-linear correction

non-linear post correction
non-linear post correction
non-linear post correction
non-linear post correction

Post solve correction


Successive relaxation until
convergence
Guaranteed length preservation

Cheap simulation of kinfinity
non-linear post correction

How to implement?

Cloth simulation literatures



Provot 1995 (position only)
Bridson 2002 (impulse)
Hair-specific relaxation possible
non-linear post correction

Provot1995



Simulates biphasic spring
Apply correction until
convergence (or time limited)
Non-linear, Non-dynamic
inverse kinematic procedure
non-linear post correction

Bridson2002


Momentum preserving
impulse
Non-linear Jacobi vs
Gauss-Seidel
Recap
k=

Large k not good


Explicit integrator blows up
Loss of angular momentum in
implicit solvers
Recap
k=

Use post-step relaxation


Very small k ok
Explicit integrators ok
Angle preservation


Length preservation isn’t
enough
Hair tends to go back to
original shape
Angle preservation
Angle preservation

Flexion spring?

Linear spring between distant
nodes.
Flexion spring (x)


Linear Spring  Loss of angular momentum
Ambiguity in direction for angles > 180

Unwanted wrinkles in hair shape
Angle preservation

Derivation on angles


Two angles suffice (no torsion)
Energy derived from changes in
angles
Angle preservation
0
F

Angle preservation

Derivation on angles

Additional anchor point needed
at the root
Angle preservation
’= 2- 
= 2/3
=4/3
=2/3

Derivation on angles


Full angle required (360 )
Axis generation an issue
Angle preservation

Implicit integration used on
angles


Non-linear problem again
Jacobian treatment needed
Predictor-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

Predictor-corrector scheme

Implicit Filter (Predictor)

Sharpener (Corrector)

Implicit Filter (Predictor)
1.First pass-implicit integration
First implicit solve to get
new velocity

2.First pass-implicit integration
Advance
position with the
predicted mid-step velocity
3.Non-linear Correction
Apply
non-linear corrector
to get position (length) right
4.Impulse
Change
velocity due to
length preservation
Velocity
may be out of
sync after impulse
5.Second implicit integration

Filters out velocity field
Velocity field in sync
again

Recap - 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
Numerical 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
Advanced Issues

Collision handling


Standard particle-based collision handler
works seamlessly
Flexibility in collision response
Projection Invariant in implicit integration (BaraffWitkin Style)
 Direct position alternation (corrector term)

Advanced 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
 ….

Movies and Q&A






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