Large Steps in Cloth Simulation David Baraff Andrew Witkin
Total Page:16
File Type:pdf, Size:1020Kb
SIGGRAPH 98, Orlando, July 19±24 COMPUTER GRAPHICS Proceedings, Annual Conference Series, 1998 Large Steps in Cloth Simulation David Baraff Andrew Witkin Robotics Institute Carnegie Mellon University Abstract tion of xÐyields the cloth's internal energy, and F (a function of x and x) describes other forces (air-drag, contact and constraint forces, The bottle-neck in most cloth simulation systems is that time steps internal˙ damping, etc.) acting on the cloth. must be small to avoid numerical instability. This paper describes In this paper, we describe a cloth simulation system that is much a cloth simulation system that can stably take large time steps. The faster than previously reported simulation systems. Our system's simulation system couples a new technique for enforcing constraints faster performance begins with the choice of an implicit numerical on individual cloth particles with an implicit integration method. integration method to solve equation (1). The reader should note The simulator models cloth as a triangular mesh, with internal cloth that the use of implicit integration methods in cloth simulation is far forces derived using a simple continuum formulation that supports from novel: initial work by Terzopoulos et al. [15, 16, 17] applied modeling operations such as local anisotropic stretch or compres- such methods to the problem.1 Since this time though, research on sion; a uni®ed treatment of damping forces is included as well. The cloth simulation has generally relied on explicit numerical integra- implicit integration method generates a large, unbanded sparse lin- tion (such as Euler's method or Runge-Kutta methods) to advance ear system at each time step which is solved using a modi®ed con- the simulation, or, in the case of of energy minimization, analogous jugate gradient method that simultaneously enforces particles' con- methods such as steepest-descent [3, 10]. straints. The constraints are always maintained exactly, independent This is unfortunate. Cloth strongly resists stretching motions of the number of conjugate gradient iterations, which is typically while being comparatively permissive in allowing bending or shear- small. The resulting simulation system is signi®cantly faster than ing motions. This results in a ªstiffº underlying differential equa- previous accounts of cloth simulation systems in the literature. tion of motion [12]. Explicit methods are ill-suited to solving stiff equations because they require many small steps to stably advance the simulation forward in time.2 In practice, the computational cost KeywordsÐCloth, simulation, constraints, implicit integration, of an explicit method greatly limits the realizable resolution of the physically-based modeling. cloth. For some applications, the required spatial resolutionÐthat is, the dimension n of the state vector xÐcan be quite low: a reso- 1 Introduction lution of only a few hundred particles (or nodal points, depending on your formulation/terminology) can be suf®cient when it comes Physically-based cloth animation has been a problem of interest to to modeling ¯ags or tablecloths. To animate clothing, which is the graphics community for more than a decade. Early work by Ter- our main concern, requires much higher spatial resolution to ad- zopoulos et al. [17] and Terzopoulos and Fleischer [15, 16] on de- equately represent realistic (or even semi-realistic) wrinkling and formable models correctly characterized cloth simulation as a prob- folding con®gurations. lem in deformable surfaces, and applied techniques from the me- In this paper, we demonstrate that implicit methods for cloth chanical engineering and ®nite element communities to the prob- overcome the performance limits inherent in explicit simulation lem. Since then, other research groups (notably Carignan et al.[4] methods. We describe a simulation system that uses a triangular and Volino et al. [20, 21]; Breen et al. [3]; and Eberhardt et al.[5]) mesh for cloth surfaces, eliminating topological restrictions of rect- have taken up the challenge of cloth. angular meshes, and a simple but versatile formulation of the inter- Although speci®c details vary (underlying representations, nu- nal cloth energy forces. (Unlike previous metric-tensor-based for- merical solution methods, collision detection and constraint meth- mulations [15, 16, 17, 4] which model some deformation energies as ods, etc.), there is a deep commonality amongst all the approaches: quartic functions of positions, we model deformation energies only physically-based cloth simulation is formulated as a time-varying as quadratic functions with suitably large scaling. Quadratic energy partial differential equation which, after discretization, is numeri- models mesh well with implicit integration's numerical properties.) cally solved as an ordinary differential equation We also introduce a simple, uni®ed treatment of damping forces, a subject which has been largely ignored thus far. A key step in our 1 ∂E simulation process is the solution of an O(n) O(n) sparse lin- x M− F . (1) × ¨ = − ∂x + ear system, which arises from the implicit integration method. In this respect, our implementation differs greatly from the implemen- In this equation the vector x and diagonal matrix M represent the tation by Terzopoulos et al. [15, 17], which for large simulations geometric state and mass distribution of the cloth, EÐa scalar func- 1Additional use of implicit methods in animation and dynamics work in- Author af®liation (September 1998): David Baraff, Andrew Witkin, cludes Kass and Miller [8], Terzopoulos and Qin [18], and Tu [19]. Pixar Animation Studios, 1001 West Cutting Blvd., Richmond, CA 94804. 2Even worse, the number of time steps per frame tends to increase along Email: [email protected], [email protected]. with the problem size, for an explicit method. Cloth simulations of size nÐ meaning x IR O(n)Ðgenerally require O(n) explicit steps per unit simu- ∈ This is an electronic reprint. Permission is granted to copy part or all of this lated time. Because the cost of an explicit step is also O(n) (setting aside paper for noncommercial use provided that the title and this copyright no- complications such as collision detection for now) explicit methods for cloth 2 tice appear. This electronic reprint is 1998 by CMU. The original printed require time O(n )Ðor worse. paper is 1998 by the ACM. 43 SIGGRAPH 98, Orlando, July 19±24 COMPUTER GRAPHICS Proceedings, Annual Conference Series, 1998 used an ªalternating-directionº implicit (ADI) method [12]. An ing from the use of implicit integration techniques were solved, for ADI method generates a series of tightly banded (and thus quickly small systems, by direct methods such as Choleski factorization, or solved) linear systems rather than one large sparse system. (The using iterative techniques such as Gauss-Seidel relaxation or conju- price, however, is that some of the forces in the systemÐnotably gate gradients. (For a square system of n nodes, the resulting linear between diagonally-adjacent and non-adjacent nodes involved in system has bandwidth √n. In this case, banded Choleski factoriza- self-collisionsÐare treated explicitly, not implicitly.) The speed tion [6] requires time O(n2).) As previously discussed, Terzopoulos (and ease) with which our sparse linear systems can be robustly et al. made use of an ADI method for larger cloth simulations. solvedÐeven for systems involving 25,000 variables or moreÐhas Following Terzopoulos et al.'s treatment of deformable surfaces, convinced us that there is no bene®t to be gained from using an ADI work by Carignan et al. [4] described a cloth simulation system method instead (even if ADI methods could be applied to irregular using rectangular discretization and the same formulation as Ter- triangular meshes). Thus, regardless of simulation size, we treat all zopoulos et al. Explicit integration was used. Carignan et al. recog- forces as part of the implicit formulation. Even for extremely stiff nized the need for damping functions which do not penalize rigid- systems, numerical stability has not been an issue for our simulator. body motions of the cloth (as simple viscous damping does) and they added a force which damps cloth stretch and shear (but not bend). Later work by the same group includes Volino et al. [20], 1.1 Speci®c Contributions which focuses mainly on collision detection/response and uses a tri- Much of the performance of our system stems from the development angular mesh; no mention is made of damping forces. The system of an implicit integration formulation that handles contact and ge- uses the midpoint method (an explicit method) to advance the simu- ometric constraints in a direct fashion. Speci®cally, our simulator lation. Thus far, the accumulated work by this group (see Volino et enforces constraints without introducing additional penalty terms in al. [21] for an overview) gives the only published results we know of the energy function E or adding Lagrange-multiplier forces into the for simulated garments on moving characters. Reported resolutions force F. (This sort of direct constraint treatment is trivial if equa- of the garments are approximately two thousand triangles per gar- tion (1) is integrated using explicit techniques, but is problematic ment (roughly 1,000 nodal points) [21] with running times of sev- for implicit methods.) Our formulation for directly imposing and eral minutes per frame for each garment on an SGI R4400 150 Mhz maintaining constraints is harmonious with the use of an extremely processor. fast iterative solution algorithmÐa modi®ed version of the conju- Breen et al. [3] depart completely from continuum formulations gate gradient (CG) methodÐto solve the O(n) O(n) linear sys- of the energy function, and describe what they call a ªparticle- tem generated by the implicit integrator. Iterative× methods do not basedº approach to the problem. By making use of real-world cloth in general solve linear systems exactlyÐthey are run until the solu- material properties (the Kawabata measuring system) they produced tion error drops below some tolerance threshold.