Physical Model for Rendering Realistic Cloth
Joe Elizondo & Andrei Margea
CS384G
Fall 2010

Introduction

For our final project, we attempted to simulate realistic fabric. We used a basic model described in the 2002 SIGGRAPH papers Stable but Responsive Cloth and Robust Treatment of Collisions, Contact and Friction for Cloth Animation. The focus of the former is a cloth simulation built from a particle system that uses a mass-spring model to achieve realistic bends and buckles. The latter paper is concerned with the intersection between cloth and objects and cloth with itself.

Model

Type 1 Forces

Particle systems have been found to be an efficient way to model materials such as cloth. A rectangular sheet of cloth is simulated by a grid of particles. A particle is joined to its 8 neighbors: up, down, left, right and diagonal, (if the particle is at a vertex of the cloth, it has only 3 neighbors and if it's on an edge it has 5) using connective springs which have forces associated with them that keep the particles from moving too far from one another. Springs in the horizontal and vertical directions are called structural springs, they maintain the structure of the cloth. Springs that connect particles diagonally are shearing springs, they are meant to control the angle between the particles that are originally orthogonal to one another. Altogether these springs help to avoid unrealistic stretching, bending, and skewing in the material. The forces generated by the springs mentioned above are called Type 1 forces. The spring force is determined by a spring constant and by how "stretched" the spring is. If Type 1 springs are compressed there is no force. Another force that is always at work is gravity. In our system gravity has the same effect on each particle since we assigned particles equal mass. A common problem that can occur at this point is perpetual oscillation. In order to deal with it a damping factor is generally used. This damping constant decreases the Type 1 force, so its impact becomes gradually smaller until the system reaches a state of equilibrium. This damping factor can be interpreted as being the factor which is responsible for friction with the air, which naturally ends oscillations. We took this approach in our work.

 

Video 1 shows the particles and the Type 1 springs (only) in the cloth.


 

Video 2 shows the actual cloth with only Type 1 forces acting on it.

Type 2 Forces

Each particle is also attached to every other adjacent particle by a spring. These springs serve the purpose of keeping these particles from getting too close to one another, therefore simulating buckling. The springs are controlled by a flexural rigidity constant, which is the equivalent of the Type 1 force spring constant. For very small flexural rigidities, the cloth acts as if there were no Type 2 forces, whereas for large values it is very rigid and resistant to bending. The following 2 videos illustrate this fact. Choi [2] advocates a method for determining the Type 2 forces that should be added to springs that makes use of inverse sinc. The explanation for his choice of inverse sinc (based on our findings we presume it works) was not convincing to us and we were further dissuaded from going this route when he advocated approximating inverse sinc with a polynomial function. Instead we realized that we simply needed a function that returned values that when applied to our model produced forces that were realistic in their resistance to bending. This is much more a function of the distance between the two particles than it is the order of a polynomial and after some experimentation we realized the polynomial used in calculating this bending force was almost arbitrary. We experimented with 2nd order, 3rd order, 4th order, and 5th order polynomials and when distance is held constant the difference in force is hardly noticeable. There doesn't seem to be anything extraordinary about inverse sinc when a function for bending force is needed. We settled on a function we liked that was used by Pabst et al.[5] and we provide it here for educational purposes. We found it produced suitably realistic results.

f(d) = 5.0×10-5d2-0.0211d + 3.46


 

Video 3 shows the particles and the Type 2 springs added.
(Unfortunately, they can't be seen very well because they overlap with the Type 2 springs.)


 

Video 4 shows the actual cloth with Type 1 & 2 forces acting on it.

Integration Methods

The Explicit Euler Method

Since we are dealing with positions of particles, forces, velocities and acceleration, the system can be described using a system of differential equations. In order to calculate these variables at different time steps we implemented the explicit Euler method, which simply approximates the values of some variables at time t+Δ given their values at time t. It is called explicit because it used an equation of the form Y(t + Δ t) = F(Y(t)), where Y(t) is the state of the system at time t and Y(t + Δ t) is its state after a small time step Δ t. This method is quite straight forward to implement, but in some situations (when we are dealing with stiff equations) obtaining a good approximation using the explicit Euler method may require too small a time step to to have a small error.

The Implicit Euler Method

In order to avoid this inconvenience, we also implemented the implicit Euler integration method. While it requires a bit of extra computation, it takes much less computation time to use it with larger time steps to achieve a given accuracy even taking into account that we need to solve an implicit equation at each time step. In the implicit method, the equations are of the form G(Y(t + Δ t) , F(Y(t))) = 0.

The Mid-Point Method

We also implemented the mid-point integration method which is the simplest example of the Runge-Kutta integration method. The mid-point method is also referred to as the second order Runge-Kutta method. It is also an explicit method for solving the initial value problem, as in the explicit Euler method.

Collision Handling

Cloth-Surface Collisions

Another goal of this project was to handle collisions with other objects. We implemented collision handling for two types of objects spheres and planes. We call the objects that we have implemented collision handling for intersect surfaces. When intersect surfaces are created they are given two properties that are passed in as parameters to our interface, friction and resilience. Friction determines how the cloth glides along the surface. Friction can be between [0-1] in our system. Resilience refers to the objects resilience to bounce off of a surface. Resilience is also set between [0-1]. Our collision handling for intersect surfaces is simple but effective. When a particle in our cloth particle system is determined to be some distance within epsilon apart from an intersect surface at any given time step we set the particle's position to be on the surface at the point of intersection.

Cloth Self-Collisions

We also took up the challenge to handle self-intersection in our cloth model based on the work done by Brideson et al.[1] Preventing collisions among cloth particles themselves is a much more difficult task because the cloth is in motion. In the time alloted we managed to handle self intersection detection. Handling the collision itself turned out to be more of a challenge than we anticipated. This is because it requires calculating a repelling force to separate two particles that are moving toward each other after they reach some distance within epsilon. Our method for detecting intersection is as follows. We sweep through the particles in a preprocessing step breaking the cloth up into triangular patches. Our cloth class contains a linked list of triangles that sum together to equal the area of the cloth. The triangles are assigned in row major order and there are (h-1)(2w-1) triangles where h is the height of the cloth in rows of particles and w is the width of the cloth in columns of particles. We then perform a three part test of order O(P*T), where P is the number of particles and T the number of triangles, for a piece of cloth. We iterate through the particles and for each particle we iterate through the triangles. For each triangle, ignoring those that are adjacent, we test if the particle is within a distance of epsilon to intersecting with the plane that the triangle lies in. If the distance is close we use Moeller and Trumbore's ray triangle intersection algorithm [3] to determine if the particle is within the triangle. If the particle is within the triangle then we have detected a collision and apply a force to the particle strong enough to repel it from the triangular patch of cloth. There is much room for improvement with this method. There are a number of methods to subdivide the space and reduce the number of particle-triangle comparisons that take place. Using a hierarchical bounding volume method would greatly reduce the number of comparisons required and ideally we would have had time to implement this technique. Also particle-triangle intersection is not sufficient to deal with collisions that occur among edges. We experimented with another algorithm by Moeller[4] to detect collisions among triangles. This is another technique that could be very effective when pair with a hierarchical bounding volume technique. The implementation only needs to take care to apply the repelling force appropriately over all the vertices of each triangle. Our collision detection code can be toggled off and on by setting the last input parameter to 0(off) or not 0(on).

Interface

In considering where to start with this project we weighed the idea of using a previous project as a jumping off point. We threw this idea away quickly because we felt that a clean start, without extraneous code, would be easier for everyone in the long run. We started from scratch and built a very simple interface using openGL that consists of a simple render window. Rotation and zoom within the window are handled by keystrokes and can be used during the animation sequence as shown in the videos on the page. There are a number of parameters that can be set that will greatly effect the properties and realism of our cloth. These parameters are passed in from the command line. The simplest way to pass in these parameters is to put them all in a text file and pipe them to the executable. In our work we create a text file of ideal parameters that we found to be quite realistic. It is also worth noting that the system can be quickly made unstable by choosing parameters unwisely. Mass and dt are the most sensitive.

Spring Constant (Ks) Determines the stretch allowed in springs of type 1.  
Spring Damping (Kd) A force that acts to dampen spring forces to reduce perpetual oscillation  
Flexural Rigidity (Kb) The resistence to bending in springs of type 2.  
Friction Surface friction  
Resiliance Resiliance to bounce  
Mass Particles mass  
dt Delta time  
Iterations per draw Number of integration steps per openGL update  
Integration Method Choose between our three integration methods, Euler, Implicit Euler, and the midpoint method.

e - Euler

i - Implicit Euler

m - Midpoint method

Render Style Choose between a wireframe or solid cloth rendering

w - wireframe

s - solid checker pattern

Toggle Self Intersection Detection For amusement purposes only, the particle-triangle pair positions are printed to standard out when a collision is detected.

0 to turn off

not 0 to turn on

Here is a set of input parameters we liked. They can be found in the tar file as 'idealparam'.

Ks Kd Kb friction resiliance mass dt iterations method style self-intersect dectect
20 5 200 0.6 0.1 0.01 0.01 20 m s 0

Source code: cloth.gz

References