Cloth Simulation Comp259 / Spring 2002 Samir Naik 2/6/02 Overview • • • • Applications of cloth Cloth Modeling Cloth Dynamics and Simulation Demos.

Download Report

Transcript Cloth Simulation Comp259 / Spring 2002 Samir Naik 2/6/02 Overview • • • • Applications of cloth Cloth Modeling Cloth Dynamics and Simulation Demos.

Cloth Simulation
Comp259 / Spring 2002
Samir Naik
2/6/02
Overview
•
•
•
•
Applications of cloth
Cloth Modeling
Cloth Dynamics and Simulation
Demos
Applications of cloth
• Movies, games, VR.
• Try to find a room without cloth!
– We can usually just texture map static objects
• Try to find a person not wearing clothes!
– Texture mapping clothes doesn’t look good on
animated characters
• Need to simulate movement of the cloth
Motivation
• Texture mapped clothes vs. simulated
Cloth Modeling
• D.E. Breen, D.H. House and M.J. Wozny, “Predicting the
Drape of Woven Cloth Using Interacting Particles,”
SIGGRAPH '94 Conference Proceedings, (Orlando, FL,
July 1994) pp. 365-372
• Getting the final configuration (drape) of cloth to look
right.
– Static, not dynamic modeling.
– What would this shirt look like made from cotton rather than silk?
– Would this dress have a more pleasing drape if made from silk
rather than light wool?
Cloth Modeling
• Example of draping cloth over objects
Particle-based model
• Cloth fibers and crossings
• Approximated by mass-spring particle
system.
Particle-based model
Particle-based model
• Categorizing thread motion
–
–
–
–
Thread collision
Thread stretching
Out-of-plane bending
Trellising (shearing)
• Energy equation
– Ui = Urepel i + Ustretch i + Ubend i + Utrellis i + Ugrav i
Energy equation
• Energy equation
– Ui = Urepel i + Ustretch i + Ubend i + Utrellis i + Ugrav I
• Urepel. Artifical repulsion energy, keeps particles a minimum distance
apart. Simple approach to collision detection.
• Ustretch. Energy of tensile strain between each particle and it’s 4
neighbors
• Ubend. Energy due to out of plane bending.
• Utrellis. Energy due to bending around a thread crossing.
• Ugrav. Potential energy due to gravity.
Repel and stretch
Repel and Stretch
• Repel forces
R(rij ) 

Co (  rij )5 / rij
{0

rij
rij>
• Stretch forces
S (rij ) 
0
{ C ((r  ) /  ) 
5
o
ij
rij
rij>
Repel and stretch
• Repel and stretch energy function are stiff
since most cloth doesn’t deform too much.
Energy equations
• Repel and stretch equations are about the
same for all types of cloth
– Can derive equations from trial and error
• Bend/shear equations are different for
different types of cloth (wool, cotton, etc).
Changes.
– Derive equations from empirical mechanical
data.
Kawabata system
• Physically measuring cloth properties.
• Approximate actual cloth energy functions
with simpler functions.
– Use piecewise linear and quadratic polynomials
that interpolate inflection points of real curve
Bending equation
Bending
• For each particle i, Mi is the set containing 6
ij angles
i1
i4
i2
i6
i5
i3
Bending
• Bend energy equation comes from
measurement
Bending
• Bend energy in one direction
Trellising (shearing)
Trellising(shearing)
• Trellising energy equation also comes from
measurment
Trellising (shearing)
• Shear in one direction
T   F cos(  )ld
Results
Results
Cloth Dynamics
• Breen wanted cloth to look good in static
poses
– Time step could be very small because
simulation time was done off line
• VR/games want cloth to look good when a
user is interacting with it.
– Need simulation to be real time, so we need
larger time steps (dt >.03 sec)
Integration
• Purpose of integration
– Given the known position x(to) and velocity
v(to) at time to
• Find a new position x(t0+h) and velocity v(to+h) at
time t0+h
Explicit integration
• Forward Euler’s method
– Based solely on conditions at to
– Takes no notice of wildly changing derivatives
and proceeds forward blindly
Explicit integration
• BAD! Step size must be really small or
simulation will blow up.
• Could use RK4
– Better smoothing function
• Force is sampled more times during time step.
– A little more stable, but still has same problems
• Collisions introduce discontinuties, and RK4 doesn’t
like discontinuities.
Explicit integration
• DEMO - when things blow up
– Clothy by Jeff Lander
Implicit integration
• Backwards Euler method
Backwards Euler
• Start from output state (x0+dx, v0+dv) and
use a forwards Euler step to run the system
backward in time.
– i.e. taking the step -h(v(t0+h), f(x(t0+h),v(t0+h)))
brings you back to (x0,v0)
• Forces an output state whose derivative at
least points back to where you came from.
– Sanity checking!
Backwards Euler
• We still consider forces to be constant
within time step
– But now output state will have consistent forces
that will not give rise to instabilities
Backwards Euler
• We must compute f (x0+dx, v0+dv)
– To avoid iteration do a first order
approximation
– Substituting this in we get
Backwards Euler
• Grouping all v terms together
• Solve for v and x
Baraff/Witkin
• David Baraff, Andrew Witkin, “Large Steps in Cloth
Simulation,” SIGGRAPH '98 Conference Proceedings,
(Orlando, FL, July 1998) pp. 43-54
Cloth Energy
• Breen describes cloth behavior as energy U,
which was to be minimized
• Baraff describes behavior in terms of a grid
of conditions
– can be simple: C(x) = |x - |
– or more complicated: Cij(x) = k(  rij )5 / rij 
– we want C(x) == 0
Forces
• Energy function
– k is a stiffness constant
• Force function
Force derivatives
• Need force derivatives for backwards Euler
– With respect to x
• K is a sparse matrix
– With respect to y
• Since C(x) doesn’t depend on v, the matrix f/v is
zero
Stretch/compresson
• Particles have fixed plane coordinate (ui,vi)
• w(u,v) is a linear function over each triangle
– maps from plane to world space
• Stretch can be measured by examining
derivatives
• wu= w/u
• wv= w/v
Stretch/compression
• What is this function “w”?
– Approximate as a linear function over triangle
x1
x2
World coords
(u1, v1)
(u2, v2)
Plane coords
Stretch/compression
• Condition for stretch energy
– a is area of triangle in uv (plane) coords
– bu and bv are usually 1, but can be changed to
lengthen and widen certain parts of cloth
• i.e. the cuff on a shirt sleeve
Shear and bend forces
• Inner product
wv
wu
=0
should be minimized
wv
wu
!= 0
Damping
• Damping should only occur in direction of
systems velocity
• This looks similar to our force equation
Derivative of damping force
• With respect to x
– drop
symmetry’s sake
• With respect to v
term for
Mass Modification
• Tricky way to constrain points
– Make mass infinity. It won’t move!
• We actually have a 3x3 inverse mass matrix
– so mass is actually a vector
• can constrain motion in each axis separately
– e.g. no acceleration in z axis
Results
Verlet Integration
• Implicit
• Velocity-less
– store current position x and prev position x*
• Update step
x = x-x* + ah2
= x-x* + h2(f0/M)
Verlet integration
• Update step
x = x-x* + h2(f0/M)
• x-x* is approximate velocity
• Since velocity is implicitly given, it is hard
for velocity and position to come out of
sync.
• Damping
x = .99(x-x*) + h2(f0/M)
Verlet cloth
• Thomas Jakobsen, “Advanced Character
Physics”, GDC 2001
• Simplify everything by constraining
particles by rods not springs
– At each iteration, rod goes back to it’s rest
length
– Solve by local iteration
• Each constraint tries to satisfy itself, let the other
constraints worry about themselves
Verlet cloth
• Pros
– fast
– stable
• Cons
– not physically based
• loss of energy in system
• can’t minimize bending/shearing easily
Verlet cloth
• Demo