
Devil
in the Blue-Faceted Dress: Real-Time Cloth Animation
By
Jeff
Lander
Gamasutra
March
27, 2000
URL: http://www.gamasutra.com/features/20000327/lander_01.htm
I’ve
been describing methods of dynamic simulation using mass and spring systems
for the past couple of months. These techniques dramatically increase the realism
in your real-time graphic simulation. One of dynamic simulation’s key benefits
is that it creates a scaleable game experience.
Users
with more powerful systems get a more realistic experience, while users with
less powerful systems are still provided with a complete experience. It’s a
situation analogous to the use of levels of detail in your 3D models. Particularly
in the PC market, where target systems can vary widely, these techniques have
become a crucial weapon in the developer’s arsenal.
For
a current project, I decided to maximize the use of dynamics to increase realism
wherever possible. The project focuses on characters in moody interior environments.
It occurred to me that the use of cloth animation in my scenes would be crucial
to creating the mood I was trying to establish.
![]() |
|
The
devil wears an animated-cloth blue dress.
|
Cloth
animation is tricky. Even in the world of high-end computer graphics, it’s difficult
to get right. Most of the time, it’s wise to avoid the whole issue. Anyone who
has ever created a female character in a skirt is familiar with the problem
of the legs poking through the cloth mesh during animation. This is pretty difficult
to fix, especially if animation requires a variety of motions. It’s particularly
tricky if you are applying motion capture data to a character. Unfortunately,
it’s also a really obvious animation problem that any end user can spot. These
cloth animation problems are the reason why most digital characters are clothed
in tight-fitting gear, such as skin hugging stretch pants.
Most
loose clothing doesn’t look natural in digital art because it’s static. It doesn’t
move along with the body. It’s possible to morph the shape of the skirt to match
the motion of the character, but this requires quite a bit of detailed animation
work. Likewise, deforming the skirt with a bone system can be effective, but
not necessarily realistic.
For
my work, I wanted to create realistic cloth in the environments and on the characters.
My hardware accelerated graphics rasterization freed the processor power necessary
to make this possible. So, I set about creating a real-time cloth simulation.
The mass and spring dynamics simulation I developed in a previous column (“Collision Response: Bouncy, Trouncy, Fun) proved effective for simulating soft body objects in real time. I thought it should be possible to use these techniques to create a cloth simulation. In fact, several of the commercial cloth animation systems for 3D animation programs such as 3D Studio Max, Softimage, and Maya use similar techniques. So how do I go about creating a piece of cloth?
![]() |
|
Figure
1A. A simple
cloth grid. |
![]() |
| Figure 1B. Stretched cloth grid. |
I really want to keep the model from shearing too much. That is, I want the
space between diagonal elements of the model preserved. So, I just add a few
more springs to the grid along the diagonals creating a group of shear springs,
as you can see in Figure 2A. Run this new structure through the simulation and
the results are much better, as you see in Figure 2B.
![]() |
|
Figure
2a. Added
shear springs. |
![]() |
|
Figure
2B. A better
cloth model. |
![]() |
|
Figure
3. The interconnection of cloth springs.
|
I prefer the second method because it works within the existing spring system without the need for a new method for calculating forces. I also get the benefit of having only one calculation to optimize later. For other applications, it’s possible that the angle minimization method may work out better.
![]() |
|
Figure
4. Collision boxes
allow for the draping effect on this tablecloth. |
I already have a simulator from the March column that is capable of handling a cloth patch. I can even apply gravity to it and lock the position of individual vertices. That’s pretty interesting, but it needs some improvement to come alive. In March, I also discussed the use of planes for collision. With this same method, I can create collision boxes that enable me to simulate a tablecloth draped over a table, as you see in Figure 4.
![]() |
|
Figure
5. Collision with
a sphere. |
For
characters, a moving box is not the most realistic way to displace the cloth.
Moving bounding spheres allow much more pleasing character animation. Fortunately,
this is easy to add to the simulation. Determining whether a point is inside
a sphere is very easy. If the distance from the point to the center of the sphere
is less than the radius of the sphere, the point is on the inside. If a point
in the cloth is found inside a sphere, I have a penetrating collision. Just
like handling collisions in the March simulator, I need to back up the simulation
time to find the actual point of contact. In a sphere, contact takes place when
the distance of the point to the sphere’s center is equal to the radius of the
sphere. Now that the contact point has been established, I need to resolve the
collision. The collision normal, N, between a point and a sphere is the vector
between the point of contact and the center of the sphere. You can see this
in Figure 5. Fortunately for me, the rest of the collision response is handled
just like the collision with a plane. This means my existing collision response
code works great.
![]() |
|
Figure
6. Cloth hanging from
a pair of invisible hips. |
I can now add collision spheres to my simulation. The cloth slides realistically off the spheres. You can see how the simulation looks with two collision spheres in Figure 6. By animating the spheres along with the 3D model, I can get a nice animated hip sway and other alluring effects. The motion of the cloth continues after the animation stops, creating entertaining effects that are diffiicult to achieve with traditional animation techniques.
The application this month was actually pretty easy to build. It’s essentially the same as last month’s application, but with a few additions. There’s a function that creates the cloth patch in a sort of macro fashion. You can set the spring settings for the three types of springs. You can also drop some collision objects around and watch them interact. Find the application and the source at http://www.gdmag.com.
Acknowledgements: Special thanks to Chris Hecker of Definition 6 and Rob Wyatt of Dreamworks SKG for discussing the issue with me.
•
Provot, Xavier. “Deformation Constraints in a Mass-Spring Model to Describe
Rigid Cloth Behavior,” Graphics Interface, 1995, pp. 147-155. Also available
in electronic form at http://www-rocq.inria.fr/syntim/research/provot
•
Baraff, David and Andrew Witkin. “Large Steps in Cloth Simulation,” Proceedings
of SIGGRAPH 1998, ACM SIGGRAPH, pp. 43-54.
Jeff Lander prefers to wear comfortable loungewear when hanging out writing code at Darwin 3D. Drop him a note and let him know what the fashion conscious are wearing this spring at jeffl@darwin3d.com.
Copyright © 2003 CMP Media Inc. All rights reserved.