0% found this document useful (0 votes)
10 views5 pages

Col 0599

The document discusses the development of real-time cloth animation using mass and spring systems to enhance realism in graphic simulations. It outlines challenges in traditional cloth animation, such as issues with loose clothing and the need for detailed simulation to avoid unrealistic movements. The author shares techniques for creating a more dynamic cloth simulation, including the use of shear and flexion springs, while also addressing potential problems like excessive stretching and self-collision.

Uploaded by

rkrams1989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views5 pages

Col 0599

The document discusses the development of real-time cloth animation using mass and spring systems to enhance realism in graphic simulations. It outlines challenges in traditional cloth animation, such as issues with loose clothing and the need for detailed simulation to avoid unrealistic movements. The author shares techniques for creating a more dynamic cloth simulation, including the use of shear and flexion springs, while also addressing potential problems like excessive stretching and self-collision.

Uploaded by

rkrams1989
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

by Jeff Lander GRAPHIC CONTENT

Devil in the Blue Faceted Dress:


Real-time Cloth Animation
’ve been describing methods of dynamic simulation using mass and spring sys-

I tems for the past couple of months. These techniques excellently 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 pro-
doesn’t move along with the body. It’s
possible to morph the shape of the skirt
to match the motion of the character,
should go back and read the March
column or at least take a look at the
March source code on the Game
17

vided with a complete experience. It’s but this requires quite a bit of detailed Developer website (http://www.
an analogous situation to the use of animation work. Likewise, deforming gdmag.com).
levels of detail in your 3D models. the skirt with a bone system can be I start by creating a rectangular grid,
Particularly in the PC market, where effective, but not necessarily realistic. and then connected each point to
target systems can vary widely, these For my work, I wanted to create real- neighboring points with springs, as
techniques have become a crucial istic cloth in the environments and on you can see in Figure 1A. These springs
weapon in the developer’s arsenal. the characters. My hardware accelerat- define the rough structure of the cloth
For a current project, I decided to ed graphics rasterization freed the and so I refer to them as “Structural
maximize the use of dynamics to processor power necessary to make this
increase realism wherever possible. The possible. So, I set about creating a real-
project focuses on characters in moody time cloth simulation.
interior environments. It occurred to
me that the use of cloth animation in
my scenes would be crucial to creating The Latest “Springy” Fashions
the mood I was trying to establish.
he mass and spring dynamics sim-

Traditional Cloth Animation in Games


T ulation I developed in my Game
Developer column (“Collision Response:
Bouncy, Trouncy, Fun” March 1999)
loth animation is tricky. Even in proved effective for simulating soft
C the world of high-end computer
graphics it’s difficult to get right. Most
body objects in real-time. I thought it
should be possible to use these tech-
of the time, it’s wise to avoid the whole niques to create a cloth simulation. In
issue. Anyone who has ever created a fact, several of the commercial cloth
female character in a skirt is familiar animation systems for 3D animation
with the problem of the legs poking programs such as 3D Studio MAX,
through the cloth mesh during anima- Softimage, and Maya use similar tech-
tion. This is pretty difficult to fix, espe- niques. So how do I go about creating a
cially if animation requires a variety of piece of cloth?
motions. It’s particularly tricky if you I am going to be using the same
are applying motion capture data to a spring force formulas for the cloth
character. Unfortunately, it’s also a simulation as the ones I used in the
really obvious animation problem that March 1999 Game Developer column. If F I G U R E 1 . The devil’s animated-
any end user can spot. These cloth ani- you are unfamiliar with the dynamic cloth blue dress.
mation problems outline the reasons forces generated by springs, you
why most digital characters are clothed
in tight-fitting gear, such as skin hug- Jeff Lander prefers to wear comfortable loungewear when hanging out writing code at
ging stretch pants. Darwin 3D. Drop him a note and let him know what the fashion conscience are
Most loose clothing doesn’t look nat- wearing this spring at [email protected].
ural in digital art because it’s static. It

http://www.gdmag.com MAY 1999 G A M E D E V E L O P E R


GRAPHIC CONTENT

Springs.” The resulting cloth patch plete. If you look


looks pretty good and requires few at the structure in
springs. However, once I run the simu- Figure 2a, you may
lation, problems appear immediately as see that there is
shown in Figure 1b. nothing to keep
The simple spring connections are the model from
not enough to force the grid to hold its folding along the
shape. Much like the box in the March edges of the struc-
column, there are simply no springs to tural springs, much
maintain the shape. If I held on to only as you fold a hand-
one point, the entire surface would col- kerchief. The fibers
lapse into a single line creating a rope. that compose actu-
Not exactly what I wanted, but it al cloth run the
points out something I want to address length of the fabric
a bit later. and generally resist
I really want to keep the model from folding and bend-
shearing too much. That is, I want the ing. In order to
space between diagonal elements of simulate this effect F I G U R E 1 . The interconnection of cloth springs.
the model preserved. So, I just add a adequately, I need
18 few more springs to the grid along the to do a little more
diagonals creating a group of “Shear work. structural springs. These springs end
Springs,” as you can see in Figure 2A. My research uncovered two methods up connecting every other cell in the
Run this new structure through the for dealing with this problem. The first cloth mesh.
simulation and the results are much minimized the bend between two adja- I prefer the second method because
better, as you see in Figure 2B. cent cells by using the dot product to it works within the existing spring sys-
This new form of cloth works pretty determine the angle of bend. The sec- tem without the need for a new
well hanging from hooks on the wall. ond method simply added an extra set method for calculating forces. I also
However, if you drop the cloth on the of springs called “Flexion” or “Bend” get the benefit of having only one cal-
floor, it wads up into a big mass of springs to apply the bend force. I creat- culation to optimize later. For other
springy spaghetti. The reason for this ed the bend springs by stretching a applications, it’s possible that the
failure is that the model is still incom- spring across two cells alongside the angle minimization method may work
out better.
I now have a sufficient spring net-
work to simulate a variety of different
types of cloth. You can see how all the
springs are connected in Figure 1.

Stretch without Tearing


hese three types of springs make it
T possible to simulate a variety of
different cloth types. By varying the
stiffness of the springs, it’s possible to
F I G U R E 1 A . A simple cloth grid. F I G U R E 1 B . Stretched cloth grid. simulate anything from stiff cardstock
to stretchy nylon. For example, span-
dex would have very flexible structural
and shear springs to allow strong
stretching capability. Paper, on the
other hand, is very resistant to shear-
ing and stretching, so its springs
would be very stiff. When considering
how much a material will bend, a sur-
face like cardboard should have the
very stiff bend springs to make it resis-
tant to folding. I find experimenting
with different values for spring stiff-
ness the only real way to find adequate
surface properties.
F I G U R E 2 A . Added shear springs. F I G U R E 2 B . A better cloth model. Stiff springs can make a numerical
simulation unstable. To combat this

G A M E D E V E L O P E R MAY 1999 http://www.gdmag.com


GRAPHIC CONTENT

the radius of the sphere. Now that the F I G U R E 3 . Collision with a sphere.
contact point is established, I need to
resolve the collision. The collision nor-
mal, N, between a point and a sphere is
the vector between the point of contact
and the center of the sphere. You can
X
see this in Figure 3. Fortunately for me,
the rest of the collision response is
handled just like the collision with a
plane. This means my existing collision
N
response code works great.
I can now add collision spheres to
F I G U R E 2 . Collision boxes allow for my simulation. The cloth slides realisti-
the draping effect on this tablecloth. cally off the spheres. You can see how
the simulation looks with two collision
spheres in Figure 4. By animating the S
it’s important to use a good numerical spheres along with the 3D model, I can
integrator. The midpoint method and get a nice animated hip sway and other
Runge-Kutta integrators developed last alluring effects. The motion of the
20 month seem to do the trick nicely. cloth continues after the animation
stops. This creates entertaining effects
that are diffiicult to achieve with tradi-
Making It Move tional animation techniques. a little more. Game players with a
white-hot system should have
already have a simulator from the smooth-looking cloth.
I March column that is capable of
handling a cloth patch. I can even
Problems to Avoid and Ignore Another problem is that each spring
acts independently. This means that
apply gravity to it and lock the posi- he simulation has a couple of each spring can be stretched to a great
tion of individual vertices. That’s pret-
ty interesting, but it needs some
T problems. The first is that the way
to simulate cloth realistically is to use
extent. In many cases, the amount of
stretch can exceed 100%. This is not
improvement to come alive. In March, a lot of points in the simulation. This very realistic. Actual fabric will not
I also discussed the use of planes for takes more computation time. High- stretch in this manner. The problem I
collision. With this same method, I can end animation programs rely on a have is that I am using linear springs
create collision boxes that enable me to great numbers of particle points for when fabric actually displays a non-
simulate a tablecloth draped over a realism. Of course, in other fields, linear spring behavior. As the amount
table, as you see in Figure 2. hour-long render times are perfectly of stretch increases, the strength of
This model is interesting and realis- acceptable. In a real-time game, how- the spring increases also. The fabric
tic looking but not terribly animated. ever, this won’t get you on the cover will also stretch to some limit and
In fact, in this case it’s probably better of any game magazines. You have to then if the force continues, it will rip.
to freeze the simulation and avoid the sacrifice realism for speed. This is This is not what I want (at least for
constant recalculation. Unless, of another good area for scaling game now). This issue, which Xavier Provot
course, the wind kicks up or someone performance. If the system is running (see For Further Info) calls “the Super-
pulls on the corner. quite fast, subdivide the cloth patches Elastic Effect,” is difficult to handle.
For characters, a moving box is not Increasing the spring strength dynam-
the most realistic way to displace the ically can lead to instability problems
cloth. Moving bounding spheres allow just like any other stiff spring prob-
much more pleasing character anima- lem. Provot suggests checking the
tion. Fortunately, this is easy to add to amount of stretch in each spring and
the simulation. Determining if a point if it is exceeds a set deformation limit,
is inside a sphere is very easy. If the dis- the springs are adjusted to achieve
tance from the point to the center of this limit. While I agree this solves a
the sphere is less than the radius of the definite problem, a second pass
sphere, the point is on the inside. If a through the springs is costly. For the
point in the cloth is found inside a effects I have attempted to achieve, I
sphere, I have a penetrating collision. can live with super-elastic cloth.
Just like handling collisions in the My collision system is pretty primi-
March simulator, I need to back up the tive. To make things easy, I only col-
simulation time to find the point of lide the vertices of the mesh with the
actual contact. In a sphere, contact F I G U R E 4 . Cloth hanging from a pair objects. As it stands, if a sphere is
takes place when the distance of the of invisible hips. small or the fabric stretches too much,
point to the sphere center is equal to the sphere will pass right through it. I

G A M E D E V E L O P E R MAY 1999 http://www.gdmag.com


also don’t handle self-collisions. That the fabric will resist folding. However, ates the cloth patch in a sort of macro
is, the fabric can pass through itself if I selectively delete one of these fashion. You can set the spring settings
without penalty. This could be cor- springs, the fabric will be able to fold for the three types of springs. You can
rected by placing bounding spheres at nicely where the springs are missing. I also drop some collision objects around
each vertex. However, applying the don’t know where I can use that yet, and watch them interact. Get the
sphere collision test between each ver- but I’m sure I can find a way. application and the source at
tex gets expensive. So, I just limit the http://www.gdmag.com. ■
situation so either that cloth doesn’t
pass through itself, or so that it isn’t The Application
too noticeable. SPECIAL THANKS:
he application this month was Go to Chris Hecker of Definition 6 and

Taking It to the Limit


T actually pretty easy to build. It’s
the same as last month’s, with a few
Rob Wyatt of Dreamworks SKG for dis-
cussing the issue with me.
additions. There’s a function that cre-
nce the system is working, it’s fun
O to see how it can be extended. I
mentioned the issue of tearing and rip-
ping after the fabric stretches too far. I
can monitor the spring lengths. If they
exceed a limit, the spring can be
removed from the system, effectively
tearing the fabric. I think this would be
a great way to simulate a cannonball
tearing through the mainsail of a tall
ship. This same method of breaking a
spring would work for a simulation of a
rope as well. After all, a rope is really
just a one-dimensional version of the
cloth patch.
Another dynamic effect can be
achieved by manipulating the flexion
springs. With these springs in place,
FOR FURTHER INFO
• 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.

There are also fabric simulations avail-


able for many professional 3D anima-
tion packages available either as plug-
ins or integrated into the software. I do
not know what techniques these prod-
ucts use with the exception of one. Colin
Withers of Topix created a fabric simu-
lation for Softimage based on the
Provot paper. Graciously, Topix
released the source code for this plug-
in to the public. See
http://www.topix.com for more info.

http://www.gdmag.com MAY 1999 G A M E D E V E L O P E R


GRAPHIC CONTENT

22

G A M E D E V E L O P E R MONTH 1999 http://www.gdmag.com

You might also like