Physical Simulation of Cloth

by Craig Prince and Jeff Bigham
CSE 557 - Computer Graphics
March 19, 2004

1.0 Problem and Motivation

Cloth is ubiquitous in our world but in each peice of even the most everyday peice of cloth exists a plethora of bumps, oscillations, and distortions. Cloth bends, twists, and moves in a number of interesting and surprising ways as it is acted upon by various forces and, as a result, modelling such a material is interesting in theory and has the potential for amazing results. We wanted to develop a system that would allow us to realistically simulate the physical properties of cloth. In order to achieve this goal we used the algorithm and techniques presented by Kwang-Jin Choi and Hyeong-Seok Ko in [1].

There are many potential applications of computer generated cloth simulations. Computer Animation is the most apparent, as [1] points out 90% of the body is covered in clothing so to realistically convince someone that a computer generated character is real a good cloth simulation is required. Another applications could be in clothing design, realistically rendering the final appearance/shape of cloth would be very useful.

2.0 Implementation

Our simulation of cloth included three major components. The first simulated the cloth itself including how the cloth should be modelled and how it should move through space in response to forces acting on it. The second extended this model to handle forces brough about by collisions of the cloth with other objects in the scene and the third modified the look and feel of the cloth so that it had a more velvety appearance. Each of these components are described in more detail in the following sections.

2.1 Cloth Simulation

  • Introduction -Following the example of [1] and [2] we modelled our cloth as a mesh of particles in which each particle is connected to its neighbors by individual springs (see Figure 1 below). This model seems a reasonable choice to model cloth because physical springs arrange in this manner should be somewhat stretchy but yet still tend to hold their shape and not compress in on themselves. One additional property we want which is shown in Figure 1(b) is that in addition to the normal spring response we also want our model to deal with such forces as real cloth would by allowing for buckling out of the plane under compression. Figure 1(b) shows a cross-section of the cloth in Figure 1(a) and shows how the cloth has buckled outward to reach a stable state.

    Figure 1. Connectivity of Interacting Particles [1]
    Figure 1. Connectivity of Interacting Particles [1]

  • Implementation - Because we only want (and it only makes sense) for buckling to occur during compression, following [1] we separated the forces acting on the particles into two types, one for stretching and one for compression/buckling. The springs that are responsible for responding to stretching are the connections indicated by the red lines in Figure 1 above. The generic formula for the energy in a spring system given a particular spring constant ks, the length the spring is stretched to xij and the natural length of the spring L is just
    spring energy equation
    Because we are only concerned for the moment with stretchy forces, if xij < L the energy of this force should be zero. From this, as [1] showed, the force for a particular particle i in respect to neighbor j is just
    spring force equation
    and the Jacobian of this force is then
    spring jacobian equation
    The springs that are responsible for responding to compression/buckling are the connections indicated by the blue lines in Figure 1 above. The force in compressive/buckling situations is derived somewhat similarly to the stretch force although in addition to the simple spring related energy used in the previous calculation an energy associated with the predicted curvature of the cloth due to buckling is also included. This results in a slightly different Jacobian
    compression jacobian equation
    where fb* is a force term that adds in the extra energy that can be included in compressive situations. Once we have the force equations and their jacobians (w.r.t. particle position) we can apply the forces to the system of particles.
  • Euler Integration Is Bad - While we initially tried a simple Euler integration approach as we did in the animator project, we couldn't keep this stable without introducing so much drag into the system as to make it uninteresting. Following [2] we performed a semi-implicit formulation using second-order BDF. The resulting system of equations that must be solved is then
    semi implicit equation
    In the equation above M-1 is the inverse mass matrix which is a diagonal matrix that describes the masses of the all the particles in the system. δfx is the sum of the position-dependent jacobian forces that act on the particle (i.e. the stretch and compression forces). δfv is the sum of the velocity-dependent jacobian forces that act on the particle; in our case, this includes only a damping force.

    Like implicit integration and unlike the Euler method, solving the system of equation takes into account the varying forces acting on the particles as they move throughout the entire time step. As a result, diverging and converging osciallations can be avoided resulting a much more stable particle system. In addition, as was shown in [2] by using this semi-implicit integration we are able to run our simulation with a much larger time step.

    Calculating the components of this equation, implementing the required matrix operations not included in the base library so kindly provided to us, and figuring out how to get all of this to work including debugging represented one of the most time-consuming parts of this project. However, the resulting difference in simulation quality from Euler integration is tremendous.

  • Adjustable Parameters - Our model of cloth used an pseudo-realistic physical model and almost all of the associated parameters could be tuned and, in fact, we discovered that they must be tuned in order to keep the system stable. These parameters include:

    ks :spring constant of the type 1 force that responds to stretching
    kb :flexural rigidity used in type 2 forces that respond to compression to control the rigidity the cloth has to bending out of its current plane
    kd :damping term constant that is used to calculate δfv in the final system of equations above
    mass :particle mass for the system, this affects how powerful the forces act on the system

    The two most important constants for realism are ks and kb. The constant ks controls the stretchiness of the system. The closer ks is to 0.0, the more the particles in the system will be able to be pulled apart. Figure 2 below shows the effect of varying the spring constant between 5 and 20. We see that as we increase the spring constant the cloth is much less likely to be stretched by its own weight.

    Figure 2. Effect of varying the stretchiness of the cloth
    Figure 2. Effect of varying the stretchiness of the cloth

    The constant kb controls how prone the system of particles is to bending/buckling. The closer kb is to 0.0, the less resistance there is to buckling. Figure 3 below shows the effect of varying the rigidity constant between 0.4 and 0.05. We see that as we decrease the constant the cloth gets more and more bumpy/wrinkly.

    Figure 3. Effect of varying the rigidity of the cloth
    Figure 3. Effect of varying the rigidity of the cloth

    The constant kd simply controls how responsive the system is to movement. Since this term introduces a damping to the movement of the particles the higher the terms the less likely a particle is to continue travelling after a short impluse force. Finally, the mass controls how heavy each part of the cloth is. Since gravity is mass-dependent, changing the mass has a similar effect to Figure 2, causing the cloth to stretch more as the mass increases because of its own weight.

  • 2.2 Collisions

    Our collision detection used Axis-Aligned Bounding Box hierarchies to segment both the cloth and scene, as suggested by [3]. We generated these hierarchies at the start of the simulation and update the hierarchies of the dynamic objects in realtime. We did not do per-triangle collision detection, instead we relied on the fact that our scene was well-enough tesselated so that if two triangles will intersect, then it is likely that the vertices of these triangles were close to each other (i.e. within some epsilon ε). This assumption greatly simplified the collision detection implementation and performance; and allowed the detection to be done with a minimal amount of overhead to the system. We can see from the figure below that this method is not completely accurate. Figure 4 below shows two screenshots of cloth draped over a dragon statue. Figure 4(a) has collision detection done with an ε of 0.08. Notice how portions of the underlying mesh pierce the cloth. Figure 4(b) shows the "fixed" version using an ε of 0.15. While the mesh no longer pierces the cloth, you can see that the cloth actually floats higher above the surface than before. This is a result of the ε being larger.

    Figure 4. Shows how our collision method can fail
    Figure 4. Shows how our collision method can fail

    Our collision response model is simple. When we detected that after moving a particle a collision would occur we simply didn't move that particle. In addition we set that particle's velocity to zero. This prevented particles from getting close to any vertex and thus prevented the neighboring triangles from intersecting any other triangles. By the nature of our semi-implicit integration (see Section 2.1 above), by setting the velocity to zero we essentially give the particle some "bounce" in the opposite direction it was travelling. This effect can be seen in the cloth simulation video below -- the cloth essentially bounces off the ground when it reaches the bottom of the dragon.

    2.3 Velvety Cloth

    After simulating our cloth we processed the final scenes using a ray-tracer. We modified the ray-tracer to implement a more complex lighting-model than the tradition Phong lighting-model. We used a method of Minnaert shading described in [4]. The method attenuates the color of a surface based not just on the angle between the light and normal, but also on the angle between the viewer and normal. This has the effect of giving our cloth a "velvet-like" appearence. The resulting lighting calculation is as follows:

    new_color := color * (NL)k * (NV)1-k

    Figure 5 below demonstrates the effect that is achieved by using the velvet rendering technique we implemented. In addition to the difference between the diffuse and velvet, we also show the result of varying the constant k in the equation above.

    Figure 5. Comparison of regular Phong shading to our implemented Minnaert shading
    Figure 5. Comparison of regular Phong shading to our implemented Minnaert shading

    Notice that the color of the Minnaert shaded cloth is overall much darker. Notice also that when the Minnaert constant (k) is high we select the portion of the highlight that is pointed toward the light, but as we reduce k we select the portion of the highlight that is facing the viewer. The effect is subtle, but gives the cloth a more life-like appearance.

    3.0 Results

    Many parameters existed in our cloth simulation that we were able to tune. These included such things as the spring constant, the buckling constant, the velvety feel constant, the drag constant, as well as such things as the particular directions and magnitudes of the forces acting on the particle system. We found that changing these often resulted in unstable systems that would either explode or implode on itself. Certainly to some limited extent we could change the stretchiness of the cloth but we found that there was actually a fairly limited range of values that both allowed for good simulation and looked reasonable. In Section 2.1 (Adjustable Parameters) we show results for varying the spring constant and buckling constant.

    To demonstrate our final simulation results we created two videos. The first video, Video 1, demonstrates the bending and dynamics of falling cloth that is held by its corners. This shows how our simulation can create physically realistic cloth. The second video, Video 2, demonstrates the dynamics of collision detection. A piece of cloth falls atop a small dragon statue. After the cloth deforms around the statue, we remove the statue and the cloth realistically curls and falls to the ground.

    Cloth Video
    Video 1. Cloth Dynamics
              Dragon Video
    Video 2. Dragon Collision

    4.0 References

    [1] Kwang-Jin Choi and Hyeong-Seok Ko. 2002. "Stable but Responsive Cloth". In ACM Transactions on Graphics, 21(3):604-611, SIGGRAPH 2002.
    [2] David Baraff and Andrew Witkin. 1998. "Large Steps in Cloth Simulation". In Proceedings of SIGGRAPH 98, ACM Press/ACM SIGGRAPH, Computer Graphics Proceedings, Anual Conference Series, ACM, 43-54.
    [3] Robert Bridson, Ronald Fedkiw, and John Anderson. 2002. "Robust Treatment of Collisions, Contact and Friction for Cloth Animation". In ACM Transactions on Graphics (TOG), v.21 n.3.
    [4] nVidia Corporation. 2002. "Pixel Shading Lab: Minnaert Shading". nv20 Developer Workshop. Src: