Narnia

Physics of Hair
Maxim Bovykin
Hair Dynamics
 Used for fur, long hair, grass…
 Started with short hair / fur
 Evolved into longer, human hair
 Proprietary Algorithms
Writing hair simulator
 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
 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
Hair is a non-linear problem
 Rigid Joint (linear in angles)
 Non-linear constraints
 Mass Spring (linear in position)
 Non-linear in angles
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
F
v  v  dt
m
n 1
n
n 1
x  x  dtv
n 1
n
xj
Basic Mass Spring System
F
v  v  dt
m
n 1
n
n 1
x  x  dtv
n 1
xi
xj
n
L
Basic Mass Spring System
xi
F
v  v  dt
m
n 1
n
n 1
x  x  dtv
n 1
xj
n
Fj
Basic Mass Spring System
xi
F
v  v  dt
m
n 1
n
n 1
x  x  dtv
n 1
xj
n
Fj
Basic Mass Spring System
F
v  v  dt
m
n 1
n
n 1
x  x  dtv
n 1
n
How large is k ?
F
v  v  dt
m
n 1
n
n 1
x  x  dtv
n 1
n
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=
v
n 1
F
 v  dt
m
 implicit integration?
n+1
n
F n
F 

v  v  v  dtM  Fn  dt
(v  v ) 
v 
x
v


F n 
1 F
2
1 F
1 
n
( I  dtM
 dt M
)v  dtM  F  dt
v 
v
x
x 

n 1
n
x n 1  x n  dtvn 1
1
Implicit integration – a closer look
Damping
Filter
Implicit integration – a closer look
F
F n 
2
1 F
1 
n
( I  dtM
 dt M
)v  dtM  F  dt
v 
v
x
x 

1
Filter

Damping
Implicit integrator adds stability through


Wider filtering of velocity
Artificial Damping
Implicit integration as a filter
F
F n 
2
1 F
1 
n
( I  dtM
 dt M
)v  dtM  F  dt
v 
v
x
x 

1
Damping
Filter
*
Velocity Field
=
As k becomes larger,
Implicit filter widens
F
F n 
2
1 F
1 
n
( I  dtM
 dt M
)v  dtM  F  dt
v 
v
x
x 

1
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
F
F n 
2
1 F
1 
n
( I  dtM
 dt M
)v  dtM  F  dt
v 
v
x
x 

1
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)
 Goldenthel 2007 (CLM)
 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
velocity filter
 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
F
F n 
2
1 F
1 
n
( I  dtM
 dt M
)v  dtM  F  dt
v 
v
x
x 

1

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)
v
n
1
2
n 1
dt F
v 
2 m
n
n

Sharpener (Corrector)
x n 1  x n  dtv
~
x n 1  x n 1  x corr
v~

1
2
Implicit Filter (Predictor)
v
n
1
2
n 1
v
 v~
n
n
1
2
1
2
x corr

dt
dt F n 1

2 m
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
Hair Dynamics – Collision Detection
•
•
Simple collision detection algorithm:
Calculate distance between core
shapes (line or rectangle)
Subtract appropriate offset (radius of
each SSV)
Hair Dynamics – hair hair interaction
Hair Hierarchy
Subdivision of Hair
Subdivision of Hair
The End - Q & A