Professional Documents
Culture Documents
Implementing Fast Cloth Simulation With Collision Response
Implementing Fast Cloth Simulation With Collision Response
j∈k
(Vk dt 2
+ Wk dt ) on the state of the system, and whose inverse can be
precomputed. This is a drastic simplification of the
problem for which the "exact" force derivatives are usually
We can see that the computation of these products can anisotropic. However, it sometimes makes sense to alter
be performed efficiently, for each successive force some purely anisotropic components by adding to them
contribution in the mechanical system, this process being some isotropic contributions. There are two several reasons
directly embedded in the Conjugate Gradient algorithm. for this:
This is indeed likely to be more efficient than building In some situations, the anisotropy orientation may
explicitly the sparse matrix, as this process includes the change drastically from one iteration to another. For
efficient factorization of constant values for contributions instance, an anisotropic elastic force derivative of a spring
related to each interactions. Generalization toward complex is only valid of the relative lateral displacements of its
interactions between several particles, such as for models extremities remains small compared to the current spring
taking into account complete surface elasticity computed length. While an isotropic derivative approximation would
on the deformed polygons of a mesh, can be obtained in overestimate the force evolution in the case of lateral
the same way. motion of the edge extremities, the anisotropic exact
derivative evaluation leads to an underestimated force not
2.4. Particle Interactions taking into account this lateral displacement (Fig.1). While
the consequence of an overestimation is only a
The V and W components defined above are stabilization the system through an apparent additional
submatrices of the size of the space dimension in which damping, the underestimation has dramatic destabilizing
the simulation takes place. For standard 3D cloth consequences for the reproduction of lateral movements.
simulation applications, this is 3. The structure of these
matrices are "constants" illustrating the variations of the
corresponding force with respect to the position and speed
of a particle.
The structure of these matrices is symmetric, and can be
decomposed into isotropic and anisotropic components.
* An isotropic component relates a force variation
identical in any direction. This contribution is proportional
to the identity matrix I. Exact
* An anisotropic component relates a force variation along computation
a precise direction. If this direction is described by the
normalized vector X , the contribution is proportional to
the hermitian matrix X X T.
Among the possible forces exerted on the particles, here
are some examples of the main contributions:
* Gravitation: The resulting force F i g r a v = M i G
exerted on a particle i is constant, and there is no derivative
contribution. Anisotropic Isotropic
* Air viscosity: A simple air viscosity force extrapolation extrapolation
F i a ir = e i (P' a i r - P i ') on a particle i can be modeled to
be proportional to the speed difference between the air Fig.1. Computing the force of a spring resulting from a displaced vertex (light)
speed (wind) and the particle speed. Thus, it has an out of the force of an initial position (dark) using anisotropic extrapolation from
isotropic derivative component W i air = -e i . If this force the derivative at this point (left), isotropic derivative approximation (right), and
is only exerted perpendicularly to the surface (along the exact computation (top).
direction of the surface normal Xi corresponding to the
particle i), this would be an anisotropic component In some simple simulation models, such as those not
W i a i r = -e i X i X i T . including any curvature force or damping, global alignment
* Elastic force: Simple spring-mass systems are based on of the particles may cause null derivatives to occur in a
particle interactions between particle couples, usually as given direction orthogonal to all interactions. When
the form of linear elasticity relations Fij e l a s t = k ij ( L ij - anisotropic derivatives are used, this degeneracy causes a
| P i - P j | ) X i j where X i j = ( P i - P j ) / | P i - P j | is the singularity in the resolution in that direction, as well as
spring orientation and L ij its native length. In this case, degenerating the equation system. Lateral forces do actually
the force derivative contribution is V i j e l a s t = - appear along these orthogonal directions if the particles are
k ij X i j X i j T . A spring viscosity force and derivative displaced, although only with a second-order evolution, and
contribution can be defined in the same way. thus not represented by first-order derivatives. For instance,
More complex interactions can be defined in similar the underestimated first-order approximation may lead to
ways. When implementing models resulting from totally incorrect equilibrium evaluations in a spring-mass
continuum mechanics (as in [BAR 98]), discretization of system with almost aligned springs (Fig.2). This however
the equations lead to expressions that can be handled in the
same way.
has to be taken in consideration, as large displacements are 2.6. Precomputed Matrix Inverses
to be expected in these directions.
The slowest part of the computation of implicit models
is the resolution of the linear system, involving the H
matrix, carried out using the conjugate gradient method as
described above. However, in some particular situations
(notably linear force models and isotropic derivatives), the
H matrix can be constant along the simulation steps. An
idea resulting from this fact, proposed in [DES 99], is the
possibility to pre-compute the inverse of the H matrix, and
L L substitute the linear system resolution by a simple matrix-
vector multiplication.
Unfortunately, the inverse of a sparse matrix is most of
the time not sparse. However, as the matrix inverse reflects
the effect of a particle's state on any other particle of the
Fig.2. In a spring-mass system containing almost aligned springs, with the system, we can suppose that the particles far away from
spring rest length L, the computation of the equilibrium position (light) from the each other only have minor effects on each other, and the
initial position (dark) using exact derivatives computed at this point is aberrant. corresponding terms of the matrix can be dropped.
It is easy to compute such a sparse inverse
If any of these problems arise, mostly when dealing approximation by iterating the conjugate gradient method a
with simple spring-mass models that do not contain any reduced number of times. The number of non-diagonal
curvature effects or any form of damping, a small isotropic elements in each inverse matrix row or columns for a
component in the derivative computation is often sufficient given number of iterations is basically the number of
to prevent instability from appearing. While only particles linked to a particle by the same number of
considering isotropic components would, more than successive interactions, which, in the case of a flat surface
stabilization, cause excessive and unwanted damping in the mesh structure, increases quadratically.
system, a linear interpolation between the isotropic and The interest of pre-computing the inverse of the H
anisotropic is often the best solution to implement. matrix can only be justified in small problems where the
entire matrix can be computed, or in problems that allow
2.5. Resolution Preconditioning enough approximations that a very reduced number of
carefully computed elements of a sparse matrix inverse
The Conjugate Gradient method is an iterative method approximation can be used. However, the conjugate
that resolves simultaneously and symmetrically the gradient method carries an inherent factorization scheme
equations of the linear system. The result of the resolution that allow to process, in a linear number of iterations, the
converges to the result of the equation system as the contributions generated from a quadratic number of inverse
number of iterations increases. The convergence rate on all matrix contributions in the case of a surface mesh
unknowns and on all equations may however not be the structure, and therefore is preferable when high accuracy is
same, depending on the relative importance of each required. The conditions required for having a constant H
equation and each unknown in the system. Preconditioning matrix also highly limit the accuracy of a model that
is a method to give more relative "importance" to certain would be computed using inverse pre-computation.
unknowns and certain equations in the resolution by
multiplying them prior to system resolution. 2.7. Fast Draping
Sometimes, the accuracy requirement is not uniform in
the entire object, and some regions of the mechanical The draping problem is a specific issue where the
system need more accuracy than others. If these regions are interest is the final rest configuration of the mechanical
quite independent, the best optimization is to perform the system, which has to be computed as quickly as possible
system resolution for each region independently. When starting from an initial configuration. What is important is
particles having various accuracy requirements are highly more the final stable position of the cloth than its
mixed in the system, the best solution is to alter the evolution.
system resolution through preconditioning techniques. A A draping model is implemented as a quasi-static model,
diagonal preconditioning matrix D should be constructed, where the speed is not taken into account. By removing the
for which the diagonal elements are proportional to the speed components in the former equations, we obtain the
relative accuracy required on each particle. Then, instead of following system:
solving the system by computing X = H - 1 Y as above,
we would rather compute X = D T ( D H D T ) - 1 D Y . P(t + dt ) = P(t ) + H −1 Y (11)
While only little complication is added to the computation
due to the simple diagonal structure of D , this extra Where:
computation could be worthwhile only when very
heterogeneous particle structures are used and particular
accuracy requirements are necessary on a reduced number of ∂P ′′ 2
H=I− dt
particles. ∂P (12)
Y = P ′′(t ) dt 2
Here, The "timestep" is more a parameter relating the P ′(t + dt ) = P ′(t ) + λ(P ′(t ) − P ′(t − dt )) + H −1 Y (14)
convergence speed than a parameter really representing P(t + dt ) = P(t ) − λ(P(t ) − P(t − dt )) + (P ′(t + dt ) − λP ′(t − dt ))dt
time. Very high values can be used, but it may degrade the
smoothness of the evolution if the system is significantly
nonlinear. This system is solved in the same way using Where:
the conjugate or biconjugate gradient method, as described ∂P ′′ ∂P ′′ 2
in Part.2.3. H=I− dt − dt (15)
∂P ′ ∂P
∂P ′′
2.8. Increasing Realism Y = (1 + λ ) P ′′(t ) dt + P ′(t ) dt 2 − 2λ (P ′(t ) − P ′(t − dt ))
∂P
While implicit methods help a lot in removing
numerical instability for large time steps, they are not This expression is not significantly more complicated
necessarily more accurate. The implicit Euler step is not than the simple implicit Euler step (2) (3), and only
really more accurate than its explicit counterpart, but this requires the additional storage of the system state of the
inaccuracy is less visible as the system is finally put to a former step. For that reason, the computation of the first
state that corresponds more to the final rest position where step of the simulation should be performed with λ = 0 .
forces equilibrate themselves, and which is obtained For most problems, we found the most adequate values of
through the knowledge of force derivatives. Globally, when λ ranging from 0.5 to 0.9.
time steps become too large, the system converges to its
rest position as if extra damping removed oscillations 3. Collision Response
excessively. For cloth simulation, curvature is particularly
affected, and bending artifacts remain without disappearing Collision response can hardly be ignored when
through excessive internal viscosity. The effect is quite performing realistic garment simulation, as the garment
visible the for simulation of stiff cloth elements, and has to interact with its environment, mostly through
should be corrected in some ways. contact effects that prevents object from interpenetrating
Additional accuracy can be obtained through the use of and also simulates friction. After being detected,
more complex integration methods. Among them, the mechanical effects of collisions have to be considered in a
Rosenbrook method provides an higher order integration suitable way. We discuss here an efficient method for
accuracy, as well as accurate integration error evaluation performing this integration in the mechanical simulation
[PRE 92]. However, this is obtained at the price of scheme discussed above.
solving four times a linear system of each integration step,
which roughly means four times more computation for 3.1. Efficient Collision Detection
each time step. While this method seems adapted for
accurate and efficient off-line computation, the time When dealing with complex situations such as multiple
necessary for computing one step is really critical for real- cloth parts animated on moving characters such as virtual
time and interactive systems, as this basically rules the bodies wearing garments, collision detection is often a
number of frames that can be computed during one second bottleneck in the simulation efficiency, and it has to be
of animation, and therefore the visual quality of the managed particularly efficiently. In such situations where
animation. collisions have to be detected between polygonal meshes
For real-time systems, we would rather prefer a "cheap" that are mostly animated, bounding techniques based on
method that does not complicate computations polygon hierarchies built on the meshes seem the best
significantly. A good solution is to use a variation of the methods, as the hierarchy structure can be kept constant as
implicit Midpoint step. This method considers the the surfaces are moving, and only the bounding volumes
evolution during the former step for increasing the accuracy need to be recomputed between each animation frame.
of the current step. Still, only one linear system resolution The hierarchical method described in [VOL 94] has been
for each step, bringing accuracy for very little additional implemented, as it provides additional efficient self-
computation. The implicit midpoint step is written as collision detection within animated surfaces using a surface
follows: curvature criteria for testing the possibility of self-
collisions within or between adjacent surface regions of the
∂P ′ ∂P ∂P ′ ∂P ′ P(t + dt ) P(t − dt ) P ( t )
I − ∂P ′′ ∂P ∂P ′′ ∂P ′ dt P ′(t + dt ) + P ′(t − dt ) − 2 P ′(t ) (13) hierarchy. This method has further been improved by
replacing the bounding boxes by bounding polyhedrons as
P ′( t ) P(t ) P(t − dt ) described in [KLO 97]. These bounding polyhedrons are
= 2 dt − 2 P ′(t ) − P ′(t − dt )
P ′′(t ) analogous to bounding boxes, but make use of more
discriminating orientations than the three axes of
One drawback of this method is the reduced robustness traditional bounding boxes, and are thus more able to
in the cases of nonlinear problems, which again may separate non-colliding parallel surfaces. We found that
become prone to numerical instability. We found a good using the six axes of dodecahedral volumes to be a good
compromise by introducing a λ coefficient which allows compromise for our problem.
progressively to scale linearly from the implicit Euler step Though being efficient, such methods are however quite
(1) (λ set to 0) to the implicit midpoint step (13) (λ set to computationally expensive, and are therefore unlikely to be
1). Turning into an equation system and after implemented in real-time systems. If the context permits
rearrangement similar to (2) (3), we obtain: it, it would be more efficient to perform simplified
approximate collision detection using some large
geometrical primitives enclosing the scene objects, such as
large metaballs whose potential field and gradient determine orientation) and friction laws (tangential component). We
the collision reactions to be applied on the particles that intend to find the collision acceleration correction ∆Pk" to
penetrate them. be applied on the collision points so that the collision
position and speed reach the desired value after a minimum
3.2. Constraint-Based Hybrid Collision Response number of time steps.
Because we have two constraints (on a value and on its
Once the collisions have been detected for a given derivative) to fulfill using only one variable (its second
frame, their effects have to be taken into account in the derivative), we need two timesteps to enforce the collision.
mechanical simulation in order to reproduce contact For finding the required successive acceleration values
reaction and friction accurately. ∆Pk"(t) and ∆Pk"(t+dt) during these two timesteps, we
There are several ways to include collision effects into a solve the following linear system:
mechanical simulation. The first is to consider collisions
as short-range mechanical forces directly handled as such in Pk(t + dt ) = Pk(t ) + Pk©(t ) dt + (Pk′′(t ) + ∆Pk′′(t )) dt 2 / 2
(18)
the mechanical model. The main drawback of this method Pk′(t + dt ) = Pk′(t ) + (Pk′′(t ) + ∆Pk′′(t )) dt
arises from the discontinuous and nonlinear nature of these Pk(t + 2 dt ) = Pk(t + dt ) + Pk©(t + dt ) dt + (Pk′′(t + dt ) + ?) dt / 22
Pk(t ) = ∑ Ski Pi(t ) Pk′(t ) = ∑ Ski Pi′(t ) (16) Fig.3. Evolution of a collision from its initial state at time t to its desired state at
i ∈k i ∈k time t+2dt.
For instance, a collision between two particles would We should now convert the acceleration correction
consider these two particles weighted by + 1 and -1. If the ∆Pk"(t) in terms of extra collision forces ∆ Fi exerted on
collision occurs on polygonal mesh elements, the weights the colliding particles. We make the assumption that this
would be the barycentric coordinates of the contact points force is proportional to the weight S k i of the particle in
with the vertices of the respective colliding mesh elements, the collision, a true assumption that preserves mechanical
one of them with opposite sign. momentum in the case of the colliding polygonal mesh
Additionally, we can compute in the same way the elements as described above. Considering that the
current "collision acceleration" Pk" resulting from the acceleration correction of a particle is the collision force
accelerations of all colliding particles resulting from the multiplied by the particle weight, we finally obtain:
mechanical model, as follows:
∆Fi(t ) = Ski Mi −1 Mk ∆Pk′′(t ) (20)
Pk′′(t ) = ∑ Ski Pi′′(t ) (17)
i ∈k
With Mk being the "reduced mass" of the collision k,
computed as follows:
The collision effect intends to enforce the desired
collision position and speed, computed from collision
reaction laws (normal component along the collision
Mk −1 = ∑ Skj2 Mj−1 (21) evaluating the performance of our algorithms, in terms of
j∈k
speed and animation quality.
Fig.2. A balancing 5000 polygon cloth with low damping and collision response.
4.2. The Cube Stack Implicit methods are low order, meaning that despite
their stability, the solution they propose is not necessary
In this layout, an horizontal, soft cloth is constrained at an accurate solution, particularly when using large
its borders. 128 cubes fall and pile up in an unstructured timesteps. Actually, they only ensure stability by
stack on this surface, which deforms under the weight "guessing" the equilibrium state of the system (by
(Fig.3). The cubes are indeed simulated as soft objects performing additional computation requiring the knowledge
using our model, but their stiffness is high, making them of the state derivatives and system resolution) and converge
appear almost rigid. The implicit model is able to deal to this guess when the timestep becomes large.
with this stiffness without any significant impact on the Many dynamical effects may disappear in these
whole simulation. approximations, leading to disturbing artifacts such as
excessive damping. For instance, having a stiff and very
refined hanging cloth rectangle, an implicit method will
efficiently pull back displaced vertices to their equilibrium
positions with respect to their neighbors, but may
completely fail to reproduce global draping effects resulting
from gravity and weak curvature forces when using refined
meshes and large time steps. The reason is that when high
curvature and complex global deformations are involved,
the complex and non-linear evolution of the system to its
equilibrium state cannot be computed only from the
knowledge of the linear derivatives at the current state. The
most observable effect are folds and wrinkles that seem not
to evolve despite all the interactions exerted on the cloth.
In some extreme cases, such a cloth would not even fall
through its own weight.
You get what you pay for, whatever technique you use
Fig.3. 128 cubes piled on a soft cloth.
for performing the simulation. In the case of explicit
methods, you have to pay for the accurate computation of
This example illustrates the robustness of collision the motion of every particle. This may take a lot of
response using the integrated algorithm described in this computational resources, but the result will be very
work. The cube pile, once it has reached equilibrium, accurate through the use of high-order methods describing
remains perfectly stable. While a method based only on the whole evolution completely. With implicit methods,
state correction, as described in [VOL 97], would be able you find a way to "cheat" the previous methods in order to
to manage piles of soft objects, the stiffness of the cube allow higher computation inaccuracy without
objects would here create instability and "vibrations" compromising numerical stability that may arise from the
because of the highly interacting collisions between the local dynamic properties of your mesh, and pay less for a
very stiff objects. Using our method, collision effects are more approximate result (but possibly realistic, as you care
actually interpreted as "collision forces" by the mechanical only for the macroscopic motion and not for all individual
model, and handled concurrently with the mechanical forces particles). This is obtained through the an evaluation of the
for reaching a global equilibrium. The collision response equilibrium position, so you have to pay some extra for
scheme however remains a correction scheme, as these this knowledge, sometimes quite much, and the first-order
"forces" are actually computed according to the system approximation you get from the current state might not be
state which is desired to reach rather than only on the valid through all the deformation range you expect. The
collision geometry. The benefit is an accurate response resulting approximations are likely to prevent the
whatever the mechanical parameters, and a mechanical reproduction of complex global dynamic motions of very
simulation globally unaltered by the numerous collisions refined meshes.
that may occur in cloth simulation.
In terms of performances, collision detection accounts
for 80% of the total computation time in this scene, 4.3. Conclusion
because of a collision detection algorithm which is not
optimized for numerous small objects moving around, as The method presented in this paper exhibits very good
in this particular configuration. We reach however more performances for systems requiring fast or real-time cloth
than a frame per second of computation on a SGI Octane. simulation. A particular way of formulating the constraints
The simulation can be considered as "real-time" when less in a particle system makes its implementation very
than twenty cubes are present in the scene. simple, and various enhancements have been proposed to
improve accuracy for rendering dynamic draping as
4.3. The Limits of Implicit Methods realistically as possible. A very general collision response
scheme based on state correction has also been proposed. It
is smoothly integrated in the numerical resolution of the
Having experimented the model on very refined meshes, mechanical simulation, and therefore provides very good
we have however found that there are some situations stability, while not altering the simulation performance.
where traditional integration methods, such as the Runge- Besides collision response, this scheme can be generalized
Kutta method used in [VOL 97], still yield much more to many other forms of constraints to be exerted on the
accurate results than the implicit methods presented here mechanical system.
and in other works. Our presented method still needs integration in a
complete real-time virtual human animation environment,
and this is the topic of the ongoing work. Among the Acknowledgements
problems to solve, the implementation of a faster collision
detection method should replace the current complete We are grateful the Swiss Fonds National pour
polygonal proximity method, which, being accurate for la Recherche Scientifique for funding the
reproducing precise contact for accurate off-line garment projects related to this work, as well as to all the
simulation, is unable to perform an approximate and fast people who contributed to this work, for
detection. A better characterization of the simulated technical help and suggestions, illustration
mechanical parameters should also be performed design and text reviewing.
This simulation method, being optimized for fast
simulation, shows however its limits when considering Bibliography
accurate simulation of complex and refined garments.
Possibly, a hybrid simulation scheme merging large-scale
high-order explicit integration with local implicit [BAR 98] : D. Baraff, A. W i t k i n , "Large Steps in Cloth
integration would provide a system with universal Simulation", Computer Graphics (SIGGRAPH’98
proceedings), Addison-Wesley, 32, pp 106-117,
application domains. There are still many challenging 1998.
topics to solve in the area of cloth simulation techniques, [BRE 94] : D.E. Breen, D.H. House, M.J. W o z n y ,
for these virtual polygonal meshes to be turned into "Predicting the Drap of Woven Cloth Using
everyone's fashion dreams, real-time, seamlessly. Interacting Particles", Computer Graphics
(SIGGRAPH’94 proceedings), Addison-Wesley,
pp 365-372, July 1994.
[CAR 92] : M. Carignan, Y. Yang, N. M a g n e n a t -
Thalmann, D. Thalmann, "Dressing
Animated Synthetic Actors with Complex
Deformable Clothes", Computer Graphics
(SIGGRAPH’92 proceedings), Addison-Wesley,
26(2), pp 99-104, 1992.
[DES 99] : M. Desbrun, P. Schröder, A. Barr,
"Interactive Animation of Structured Deformable
Objects", Proceedings of Graphic Interface,
1999.
[EBE 96] : B. Eberhardt, A. Weber, W. Strasser, "A
Fast, Flexible, Particle-System Model for Cloth
Draping", Computer Graphics in Textiles and
Apparel (IEEE Computer Graphics and
Applications), pp 52-59, Sept. 1996.
[EIS 96] : J.W. Eischen, S. Deng, T.G. C l a p p ,
"Finite-Element Modeling and Control of Flexible
Fabric Parts", Computer Graphics in Textiles and
Apparel (IEEE Computer Graphics and
Applications), pp 71-80, Sept. 1996.
[TER 87] : D. Terzopoulos, J.C. Platt, H. Barr,
"Elastically Deformable Models", Computer
Graphics (SIGGRAPH’97 proceedings), Addison-
Wesley, 21, pp 205-214, 1987.
[VOL 94] : P. Volino, N. Magnenat-Thalmann,
"Efficient Self-Collision Detection on Smoothly
Discretised Surface Animation Using Geometrical
Shape Regularity", Computer Graphics Forum
(Eurographics’94 proceedings), Blackwell
Publishers, 13(3), pp 155-166, 1994.
[VOL 95] : P. Volino, M. Courchesne, N.
Magnenat-Thalmann, "Versatile and
Efficient Techniques for Simulating Cloth and
Other Deformable Objects", Computer Graphics
(SIGGRAPH’95 proceedings), Addison-Wesley,
pp 137-144, 1995.
[VOL 97] : P. Volino, N. Magnenat-Thalmann,
"Developing Simulation Techniques for a n
Interactive Clothing System", Virtual Systems
and Multimedia (VSMM’97 proceedings),
Geneva, Switzerland, pp 109-118, 1997.
[WEI 86] : J. W e i l, "The Synthesis of Cloth Objects",
Computer Graphics (SIGGRAPH’86 proceedings),
Addison-Wesley, 24, pp 243-252, 1986.
[YAN 91] : Y. Yang, N.Magnenat-Thalmann,
"Techniques for Cloth Animation", New trends i n
Animation and Visualisation, John Wiley & Sons
Fig.4. Realistic cloth simulation. Ltd, pp 243-256, 1991.