Algorithm Search⌘K

Problemcore

Cloth simulation

Also called cloth animation.

Compute the motion of a sheet or garment that stretches little, bends easily, and collides with bodies and with itself. Stiff stretch against soft bending makes explicit steps small.

Cloth simulation asks for the motion of a thin sheet, such as a garment, a flag or a curtain, under gravity, wind and contact. Cloth hardly stretches, bends with almost no effort, and touches the body under it and itself in many places at once. These three facts make the problem hard: the stiff stretch forces limit explicit time steps, the soft bending makes fine folds, and the contacts must never let the sheet pass through anything. This page states the problem and lists the methods; each method has its own page, starting with the mass-spring system.

In plain words

A piece of cloth is cut into many small triangles or a grid of points. The computer must move every point from one frame to the next so that the cloth falls, swings and folds as real cloth does.

Cloth resists being pulled longer very strongly, but it folds very easily. A simple computer step that takes small forward guesses must use tiny time steps, or the strong pull makes the points shake and fly apart. Methods that solve for the next state as a whole can take large steps, but each step costs more.

The cloth must also never pass through the body that wears it or through itself. Points move in jumps from one frame to the next, so a check only at the end of a step can miss a crossing. Good methods check the whole path of each point during the step.

Definition

Input. A triangle mesh (or a grid) of the cloth with nn vertices and mm triangles or springs. Each vertex has a mass, a rest position in the flat pattern (material coordinates (u,v)(u, v)), a current position xi\mathbf x_i and a velocity vi\mathbf v_i. An elastic model for stretch, shear and bending, and a damping model. External forces such as gravity (0,−9.81,0)(0, -9.81, 0) m/s2^2 and wind. Obstacles given as moving meshes, a list of pinned vertices, a cloth thickness hh, a friction coefficient μ\mu, a time step Δt\Delta t and a number of frames.

Output. The positions of all vertices at each frame, such that:

  • the motion approximates the solution of Mx¨=f(x,x˙)+fextM \ddot{\mathbf x} = \mathbf f(\mathbf x, \dot{\mathbf x}) + \mathbf f_{\text{ext}} for the chosen elastic and damping forces;
  • the cloth does not intersect itself or the obstacles, and in the stronger form stays at least hh away from them;
  • contacts obey a friction law, usually Coulomb friction on the relative tangential velocity.

Cost model. The real RAM. The cost is given per time step and per solver iteration, in nn vertices, mm elements, cc contacts, kk iterations and ss substeps. An iteration count is a measurement unless a method states a convergence bound.

The goal of graphics is a plausible motion at the frame rate, not an accurate answer for one fabric. The output is judged by eye, and the parameters are tuned. Measured fabric parameters exist, but they are not part of the problem here.

Variants

  • Explicit or implicit time stepping. Explicit methods cost little per step but need steps below the stability limit of the stiffest spring. Implicit methods solve a large system per step and can take steps of a frame or more.
  • Stretch as a force or as a constraint. Most models treat stretch as a stiff elastic force. Others treat the cloth as inextensible or limit the strain to a few percent (Provot's strain limiting).
  • Bending model. Bending springs, or an energy in the dihedral angles (discrete shells, quadratic bending model).
  • With or without self-collision. A flag in the wind can skip self-collision. A garment cannot.
  • Real time or offline. Games use a few iterations of a position solver per frame and accept errors. Film uses implicit solvers and robust collision handling, and spends seconds per frame.

Examples

The step limit under refinement. Take a grid with particles of mass m=10−3m = 10^{-3} kg and stretch springs of k=103k = 10^3 N/m. One particle on one spring has ω=k/m=103\omega = \sqrt{k/m} = 10^3 rad/s, so symplectic Euler needs Δt<2/ω=2\Delta t < 2/\omega = 2 ms, and a network needs less. Halve the grid spacing for the same cloth. Each particle now carries a quarter of the mass, while a stretch spring keeps the same stiffness, so ω\omega doubles and the step limit halves to at most 1 ms. There are four times as many particles and twice as many steps, so one second of motion costs eight times as much. In general an explicit 2D cloth of nn particles costs Θ(n3/2)\Theta(n^{3/2}) per second of motion.

Stretch against bending. Bergou et al. (2006) state that for inextensible plates and shells, which they take cloth to be, the stretching stiffness is greater than the bending stiffness by four or more orders of magnitude. The bending forces then decide the shape of the folds, while the stretch forces decide the step size.

Super-elasticity. Provot (1995) hung a 17 by 17 grid of springs by two corners. With a stiffness low enough for his time step, the springs near the corners stretched by more than 100%, while woven cloth stretches by about 10% at most. A stiffer spring would need a smaller step; his fix was to limit the strain after each step.

Known algorithms

Internal forces and time stepping:

Bending:

  • Discrete shells (2003): an energy in the change of the dihedral angle of each edge.
  • Quadratic bending model (2006): a constant quadratic form for nearly inextensible cloth with a flat rest shape.

Collisions and friction:

AlgorithmTimeSpacePropertiesCode
Baraff-Witkin implicit clothΘ(n + t + e) assembly · iterationΘ(n + t + e) matrixconstraints exactdeterministicnot exactimplicit1 language
Extended position based dynamicsO(n + k c) stepO(n + c) stepnot angular momentum conservingbackward euler for linear constraintsdeterministicnot exactlinear momentum conserving1 language
Fast mass-spring simulationΘ(m + n b) iterationO(n b) factordeterministicnot exactmomentum conservingmonotone objectiveunconditionally stable1 language
Impact zonesO(p n m) totalΘ(n + m) zonesnot angular momentum conservingcollision free resultdeterministicnot exactlinear momentum conserving1 language
Position based dynamicsO(n + k c) stepO(n + c) stepnot angular momentum conservingdeterministicnot exactlinear momentum conservingstiffness depends on iterations1 language
Provot's strain limitingΘ(k m) correctionΘ(n) extraconverges when feasibledeterministicnot exactorder dependent1 language
Bridson-Fedkiw-Anderson cloth collision handlingO((1 + P + Z) (n t + e^2)) totalΘ(n t + e^2) pairsnot angular momentum conservingcollision free resultdeterministicnot exactlinear momentum conservingorder dependent1 language

Bounds

  • Lower bound per step. Any method must read and write every vertex, so a step costs Ω(n)\Omega(n).
  • Explicit methods. Θ(n+m)\Theta(n + m) per step, with a step limit that shrinks like the grid spacing, so Θ(n3/2)\Theta(n^{3/2}) per second of a 2D cloth (see the example). This is a bound in the model above, for a fixed material.
  • Implicit methods. One sparse linear solve per step. With kk conjugate gradient iterations it costs O(k(n+m))O(k (n + m)). Baraff and Witkin (1998, Section 8) measured times per frame that grow slightly better than O(n1.5)O(n^{1.5}) on their scenes; that is a measurement. With a constant matrix, as in fast mass-spring, a sparse Cholesky factor is computed once, and each solve costs the size of the factor.
  • Collisions. With a bounding volume hierarchy, a broad phase query is O(n)O(n) in the worst case and much less in practice; the number of close pairs cc is observed, not bounded. Robust handling by iterated CCD and impact zones has no useful worst case bound on the number of iterations; the impact zones make it end, because the zones only grow.

Reductions

  • One step of backward Euler reduces to the minimization of the incremental potential 12Δt2(x−y)⊤M(x−y)+E(x)\frac{1}{2\Delta t^2} (\mathbf x - \mathbf y)^\top M (\mathbf x - \mathbf y) + E(\mathbf x) with y=xn+Δt vn+Δt2M−1fext\mathbf y = \mathbf x_n + \Delta t \, \mathbf v_n + \Delta t^2 M^{-1} \mathbf f_{\text{ext}}. Fast mass-spring, projective dynamics, vertex block descent and IPC all start from this form.
  • One linearized step reduces to a sparse symmetric linear system, solved by the conjugate gradient method or by Cholesky decomposition.
  • Intersection-free motion reduces to continuous collision detection: for each vertex-triangle and edge-edge pair, find the first time in the step when the four points are coplanar and close.
  • Frictional contact can be written as a complementarity problem (linear complementarity problem after linearization); cloth methods in graphics usually solve it approximately by impulses.

Applications

Clothing of characters in film and games, flags, curtains and sails in scenes, and the virtual try-on and design of garments, where the pattern pieces are simulated before the fabric is cut.

References

  1. Donald H. House and David E. Breen (editors), Cloth Modeling and Animation, A K Peters, 2000, the whole book (models of cloth, their parameters and their numerics; general locator)
  2. Xavier Provot, Deformation constraints in a mass-spring model to describe rigid cloth behavior, Graphics Interface 95, 147-154, 1995, Section 3 (the super-elastic effect: springs stretched past 100%) and Section 4 (the critical stiffness for a given time step)
  3. David Baraff and Andrew Witkin, Large steps in cloth simulation, Proceedings of SIGGRAPH 98, 43-54, 1998, Section 1 (why explicit methods need small steps for stiff stretch) and Section 8 (running times per frame as the mesh grows)
  4. Robert Bridson, Ronald Fedkiw and John Anderson, Robust treatment of collisions, contact and friction for cloth animation, ACM Transactions on Graphics 21(3), 594-603, 2002, Section 5 (the split of internal dynamics and collision processing in one time step) and Sections 6 and 7 (proximity, collisions, friction and impact zones)
  5. Miklós Bergou, Max Wardetzky, David Harmon, Denis Zorin and Eitan Grinspun, A quadratic bending model for inextensible surfaces, Eurographics Symposium on Geometry Processing 2006, Section 1 (stretching stiffness exceeds bending stiffness by four or more orders of magnitude) and Section 3 (cloth as nearly inextensible)

About this page

The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.

LadderLevelWhat the next level needs
Human proofH0 no proof
  • add a proof in proofs/ (06.5)
LeanL0 no Lean part
  • name a Lean module in the lean field (07)
VisualV0 none
  • add viz/scene.ts or a figure (10)
WritingW2 basic
  • a contract.yaml