Date post: | 24-Mar-2015 |
Category: |
Documents |
Upload: | elsayed-hemayed |
View: | 89 times |
Download: | 0 times |
Speeding up Cloth Simulation by Linearizing the Bending Function of the Physical
Mass-Spring Model
Asmaa A. ElBadrawy and Elsayed E. Hemayed
Computer Engineering Department
Faculty of Engineering, Cairo University
Giza, Egypt
[email protected], [email protected]
Abstract—We introduce a new enhancement to speed upthe physical mass-spring model for efficient cloth simulation.The mass-spring model is known for its accuracy but slowness.The proposed technique tackles the computation burden of themodel by developing a linearization solution for the bendingfunction. The proposed technique is about six times faster thanthe traditional technique of directly evaluating the complexphysical models. The detailed of the proposed technique andits experimental results are discussed in this paper.
Keywords-Cloth simulation; bending function; physical mass-spring model;
I. INTRODUCTION
The problem of cloth simulation has more than one aspect.
This includes modeling the intrinsic properties of cloth,
handling external forces that influence textile behavior, and
handling self-collisions among textile and collisions with
other objects in the scene. Fast cloth simulation requires
handling all these aspects in an efficient way, and at the
same time maintaining plausible cloth appearance. Fast cloth
simulation is a vital requirement for a lot of interactive
applications. For example, apparel simulation for online
fitting room applications, and the computer game industry.
Physical models for cloth simulation [5], [6], [16] man-
aged to model and simulate the intrinsic properties of tex-
tiles. This enables the simulation of differnet types of textiles
by changing the model parameters. Physical models usually
produce plausible simulation results. However, they are not
efficeint in terms of performance. This is because they
use sophisticated non-linear physical equations for modeling
cloth behavior, and they use integration schemes with large
numbers of iterations. Therefore, they are not suitable for
interactive applications.
The goal of our work is to develop a technique for
fast cloth simulation while preserving -to an acceptable
extent- the ability to simulate different types of textiles. To
simulate different textiles, we use a physical model to model
intrinsic cloth properties. However, we do not implement
the underlying complex equations as they are. We first
linearize the sophisticates models, then use the linearized
versions to compute the internal forces acting on textiles
via interpolation. We also empower our technique by using a
velocity-less Verlet integration scheme which is more stable
and requires less computations per integration step compared
to other techniques. We use the same physical model that
was proposed by Choi and Ko [5]. Our technique proved to
be six times faster than the straight forward implementation
of the model. Our technique also preserved the ability to
simulate different kinds of textiles by altering the values of
the coefficients of the physical model.
This paper is organized as follows: section 2 discusses
the related research work. Section 3 presents the proposed
approach. Section 4 presents and discusses the experimental
results. Section 5 concludes the paper.
II. RELATED WORK
The problem of cloth simulation has been mainly handled
by two different models: the geometric model [11], [21] and
the physical model [1], [5], [6], [9], [10], [13]–[16], [18].
Geometric models (sometimes named Mathematical Mod-
els) focus on the appearance of cloth. They try to mimic
the external shape of cloth like folds and wrinkles, and
represent these apparent properties by geometrical equations.
They do not consider the intrinsic properties of cloth. They
consider cloth as three dimensional curves and try to find
mathematical models for these curves. They are not able
to simulate the physical properties of cloth. Accordingly,
simulating different kinds of textiles using geometric models
is not a direct task, and there are no guarantees for physical
correctness.
In physical models, various structural studies were done
on different textiles attempting to measure and model their
intrinsic behavior. The physical model preserves the internal
properties of the textile and thus enabling different textile
simulation with different motion using the same model.
This is a great advantage over geometric model. However,
Physical models are far less efficient compared to geometric
models. One simulation step using a physical model takes
more CPU cycles compared to a geometric model, and they
are accordingly not suitable for interactive applications. This
is because of the complexity of the physical equations under-
lying the physical models. Another problem with physical
2011 International Conference on 3D Imaging, Modeling, Processing, Visualization and Transmission
978-0-7695-4369-7/11 $26.00 © 2011 IEEE
DOI 10.1109/3DIMPVT.2011.20
101
model is using integration schemes with large numbers of
iterations.
Several methods were developed to speed up the cloth
simulation using physical models or to enhance its compu-
tations stability. For example, Barbic and Popovic [1] and Oh
et al. [15] addressed the problem of numerical damping in
cloth simulation. Goldenthal et al. [9] addressed the problem
of textile overstretching. Volino and Thalmann [20] proposed
a linear approach suited for the implicit integration schemes
used in particle systems such as cloth. Bergou et al. [2]
proposed an isometric bending model that reduces cloth
simulation times up to three-fold. Garg et al. [8] proposed
a hinge-based model to speed up the cloth simulation.
Bridson et al. [3] enhanced the realism of cloth simulation by
producing a cloth simulation with many folds and wrinkles.
Maintaining high simulation accuracy would inevitably
lead to an increase in computational time and vice versa.
We are developing an approach that runs in real time and
yet preserves –to some extent- the appealing look of different
textiles that result from high simulation accuracy of different
textiles achieving the performance requirements for cloth
simulation, as described by Volino and Thalmann [19];
low computational time, acceptable accuracy, and numerical
stability.
III. PROPOSED APPROACH
The cloth is represented using the mass-spring physical
model [5], [15]. It is represented as a matrix of particles
connected by a group of springs. The springs connecting
the particles are: stretch, sheer, and bending springs. The
structure, sheer, and bending connections for particle Pij
are illustrated in figure 1.
Figure 1. Connection for Pij : Stretch and sheer connections are respe-sented by straight lines, and bending connections are represented by curvedlines.
Newton’s law of motion is used to define the system
behavior. Newton’s law of motion stated that the total force
acting on a mass particle is equal to the mass of this particle
multiplied by its acceleration as shown in the equation:
F = m× a (1)
The forces acting on a particle are divided into internal
and external forces. The internal forces are the stretching,
sheering, and bending forces that exist in the springs con-
necting the particles. The external forces can be any external
factors acting on the cloth like gravity and wind. We just
account for acceleration due to gravity and air friction as
the external forces acting on cloth.
For modeling the internal forces, we use the mechanical
equations that were suggested by Choi and Ko [5]. That is,
we use linear spring equations for modeling the stretching
and sheer behavior and use a non-linear complex spring
equation for modeling the bending behavior. We use this
bending model as a case to apply our general technique to.
According to Choi and Ko [5], the force acting on a mass
point i due to a structural or sheer spring connecting it with
particle j is defined by the equation:
fi =
{
ks(|xij | − L)xij
|xij |, |xij | ≥ L
0 |xij | ≺ L(2)
Where ks represents the stiffness coefficient for stretch
and sheer, xij is the vector connecting the two mass points,
—xij— represents the current length of the spring connect-
ing the two mass points (i.e. the distance between the two
mass points), and L is the actual length of the spring under
no tension or compression forces. The force acting on a mass
point i due to a bending spring connecting it with particle
j is defined by the equation:
fi = kbk2(cos(
kL
2)− sinc(
kL
2))−1
xij
|xij |= fb(|xij |)
xij
|xij |(3)
Where kb is the flexural rigidity and k represents the
curvature of the spring connecting the mass points i and
j due to the exerted bending force:
k =2
Lsinc−1(
|xij |
L),where sinc(x) =
sin(x)
x(4)
The modified version of the bending magnitude f∗b in
equation 5 is used to mimic the imperfection in the structure
of the fabric equation 3 as pointed out by Choi and Ko
[5]. The magnitute curve for the modified bending force is
plotted in figure 2.
f∗b =
{
cb(|xij | − L) , fb < cb(|xij | − L)fb , otherwise
(5)
where cb is a constant that is usually assigned a value
comparable to ks.
This sophisticated bending model yields realistic bending
behavior and gives plausible results. The main problem with
this bending model is that it is a non-linear; it includes
102
Figure 2. The magnitude curve for the bending force given by equation5.
cosine, sinc, and sinc inverse functions that require a lot
of computations. Our technique works by linearizing the
bending function fb, figure 2. The negative sign of the
bending magnitude fb means that the distance xij is less
than the spring length due to bending. For the bending
behavior, xij can only be less than or equal to L. So the
bending magnitude fb is defined for the values ofxij
Lwhich
lies on the interval [0, 1]. To linearize this curve, we divide
the interval [0, 1] into a group of subintervals. The actual
value of fb is computed at the points defining the beginning
and ending of each interval. The two points representing
an interval is used to specify the slope and intercept of the
straight line connecting them. Then for any value ofxij
L,
we compute its corresponding fb value approximately by
applying the equation of the corresponding straight line. For
more details in how to approximate trigonometric functions
using precomputed values see Sewell [17]. Our technique is
divided into two steps:
1) Step I is an initialization step. It is performed once
before the simulation starts. This step is responsible
for dividing the interval [0, 1] –which is the interval
of the values ofxij
L- into subintervals.
2) Step II is executed once with each simulation time
step. It is responsible for computing the bending force
at each time step. It is the main part that saves com-
putations compared to calculating the bending force
according to the original equation 5. The pseudocode
is listed in figure 3.
A. Computational Savings
To compute the savings obtained by Step II, we compute
the difference in the number of performed arithmetic and
logic operations in Step II and compare it to the number
of performed operations using the original equation 5. It
should be clear that the cosine, sinc, and sinc inverse
xij ←current distance between mass particles i and jv ←
xij
L
interval← [start, end]i inPts that v lies within
line← line of intervalbaij ←approximate bending force between particles i and
jbaij ←substitute v in the equation of line defined by its
slope and intercept
Figure 3. Pseudocode for step II: Computing Approximate Bending Force
functions in equations 3 and 4 are evaluated using Taylor
series expansion. The sinc inverse function was calculated
according to the series specified by Cantrell [4]:
f(x) =
2x+3
10x3 +
321
2800x5 +
3197
56000x7 +
445617
13798400x9+
1766784699
89689600000x11 +
317184685563
25113088000000x13+
14328608561991
1707689984000000x15 +
6670995251837391
1165411287040x17
(6)
The series listed in equation 6 requires 101 multiplica-
tions, 9 divisions, 9 additions, 1 subtraction and 1 square
root operation. Table I summarizes the operations performed
in both techniques: equation 5, and the proposed approach.
Table IA COMPARISON FOR THE OPERATIONS PERFORMED BY EQUATION 5
AND STEP II IN OUR PROPOSED TECHNIQUE
Operation Equation 5from [5]
Step II in our technique
+ 9 1
− 2 0
× 105 1
÷ 13 0√sqrt 1 0
cos 1 0
sinc 1 0
comparisons 3 Avg =number intervals
2,
Max = number intervals
From table I, we can conclude that the computations done
by equation 5 are almost eleven times the computations done
by Step II in the proposed algorithm. It is clear that Step
II in the proposed technique saves a lot of computations.
Notice that the cost of Step I in the proposed approach is
considered equal to zero. This is because this step is only
performed once at the initialization. We are only concerned
with the operations performed with each time step.
The intrinsic damping force of cloth is also taken into
account as specified by Choi and Ko [5]. The internal
damping force exerted on a particle i due to its interaction
with particle j is given by the equation:
fi = −kd(vi − vj) (7)
103
Where kd is the damping stiffness coefficient, vi is the
velocity of particle i, and vj is the velocity of particle j.
Back to Newton’s law of motion: Fi = mi ∗ ai, where
Fi represents the summation of all the vector forces acting
on the particle i, mi is a scalar that represents the mass
of particle i, and ai represents the acceleration vector of
particle i. Now given Fi and mi, we can compute ai. Then
we can integrate ai using a numerical integration method to
get the velocity vector vi then integrate once more to get
the position vector xi of particle i.In our technique, we use a velocity-less Verlet integration
scheme for time integration [10]. Velocity-less means that
the velocity is approximated by the old and new positions
of the mass particles. This way we only do one integration
time step to get the positions instead of doing two integration
steps. Verlet integration is mainly used to integrate Newton’s
law of motion. It offers great stability compared to other
integration techniques. This integration scheme was used by
Gaber [7] and Jakobsen [10]:
x(t+△t) = 2x(t)− x(t−△t) + a(t)△t2 +O(△t4) (8)
It achieved real time simulation and was used in computer
games. But the authors of [7], [10] fixed the stiffness
coefficients of the springs and assumed that they are equal
to infinity. This increased the numerical stability of the
integration scheme, even with large time steps. On the
other hand, this limitation (fixing the stiffness coefficients)
prevents the simulation of different kinds of textiles. To
overcome this limitation, we remove this assumption and
deal with non-constant stiffness coefficients. To do this,
we assume different values for the stiffness coefficients
of different forces, then compute the force vectors, apply
Newton’s law of motion, and finally integrate to get the
velocity and position vectors of all cloth particles. But
removing this assumption would compromise the numerical
stability of the integration technique. This can be overcome
by slightly decreasing the time step to the extent that
preserves numerical stability and at the same time still be
large compared to the time steps used with other numerical
integration techniques.
To show the computational savings acquired by utilizing
the Verlet Integration scheme, we compare it with other
integration techniques. Given the total force vector acting
on a particle and the particle mass, we want to compute the
position vector of that particle by integration. The number
of arithmetic operations is counted for each technique for a
single integration operation. The comparison is carried out
between (1) Verlet Integration Scheme, (2) Euler Integration
Scheme, (3) Mid Point Integration Scheme, and (4) Fourth
Order Runge-Kutta Integration Scheme. The first scheme is
implemented by Gaber [7] and Jakobsen [10], and in this
work. The other three schemes were implemented by Lander
[12] who implemented a simple cloth simulation system
based on the spring-mass model and a simple collision
detection scheme for detecting collisions with a sphere. He
used three different integration schemes for time integration:
Euler, Mid Point, and Fourth Order Runge-Kutta. Table II
shows the number of performed operations by each scheme.
It is clear from table II that the Verlet scheme requires the
least number of computations per single integration time step
resulting in smaller simulation time compared to the other
techniques, even the Euler method.
Table IISUMMARY FOR THE NUMBER OF OPERATIONS REQUIRED BY EACH
INTEGRATION SCHEME TO COMPUTE THE NEW POSITION OF A MASS
PARTICLE.
Operation Verlet Euler Mid-Point
4thorderRunge-Kutta
IntegrationSteps
1 2 2 2
× 4 7 14 48
÷ 0 0 1 2
+ 6 6 12 42
− 3 0 0 0
ForceCalculations
1 2 2 3
Total 14 15 29 95
IV. EXPERIMENTAL RESULTS
In this section, we present the experimental results for
simulating different textile. The proposed approach was
tested on a machine with an Intel Pentium M735A Processor,
Intel Graphics Media Accelerator 900 with Shared Memory
of up to 128MB, 1GB of RAM, Windows XP operating
system, and OpenGL/C++ for graphics rendering.
We show four experiments; cloth hanged from 2 points,
cloth falling on a box, cloth falling on a sphere and an
experiment to analyze the trade off between speed and
quality. In the four experiments we used the following
parameters:
• Cloth matrix consists of 31× 31 particles.
• Cloth particles are connected by stretching, sheering
and bending springs.
• The friction with air is computed according to Gaber
[7].
• Verlet velocity-less integration scheme is used to inte-
grate particle positions with each time step.
• The integration time step is equal to 0.1 second.
• The particle mass is equal to 1 gram.
• The acceleration due to gravity is equal to 9.8 m/sec2
• The internal cloth damping is implemented as proposed
by Choi and Ko [5] with the internal damping coeffi-
cient kd equal to 0.0002.
A. Experiment 1: Cloth Hanged from 2 Points
This experiment shows how the proposed approach saved
enormous computations in handling the internal forces of
104
cloth . The cloth sheet is hanged from 2 points. The
simulation starts from a horizontal position and the cloth
sheet moves under the effect of gravity till it reaches an
equilibrium vertical position, see figure 4.
The time taken to compute the bending forces of all
the particles in a time step was measured for the original
equation 5, and for the proposed approach. The average
computation time of 64 time steps was 33.625 msec for
the implementation of the original equation, and was 5.875
msec for our “linearization and interpolation” technique.
Thus the proposed technique is almost six times faster than
the direct implementation method. The speed up illustrated
in this experiment applies to all the following experiments.
B. Experiment 2: Cloth Falling on a Box
This experiment shows the effect of changing the bending
stiffness coefficient on the behavior –and hence- the appear-
ance of cloth. In this experiment, the cloth sheet falls under
the effect of gravity and collides with a box. The value of
the bending stiffness coefficient kb is tested for 2 different
values: 0.0 and 0.1. The resulting effects are shown in figure
5. It is clear from the circled parts that the bending behavior
of the fabric changes when the bending stiffness coefficient
is changed. The fabric with higher bending stiffness shows
higher resistance to bending at the corners of the table.
C. Experiment 3: Cloth Falling on a Sphere
This experiment shows the effect of changing the bending
stiffness coefficient on the behavior –and hence- the appear-
ance of cloth. In this experiment, the cloth sheet falls under
the effect of gravity and collides with a sphere. The value of
the bending stiffness coefficient kb is tested for 3 different
values: 0.0, 0.1, and 0.3. The resulting effects are shown in
figure 6. Notice the difference in the behavior at the edges
of the cloth sheet.
In this experiment, it was observed that the stability of the
simulation degraded as the value of the bending stiffness
coefficient increases. For that reason, the time step was
adjusted (to a smaller value) for larger bending stiffness
coefficient. This guarantees the stability of the simulation.
In this experiment, a time step of 0.1 second was used with
the bending stiffness coefficient values 0.1 and 0.2. While a
time step of 0.05 second was used with the bending stiffness
coefficient value of 0.3.
D. Experiment 4: Speed Vs Quality Tradeoff
The bending force curve is linearized by dividing it into
a group of intervals, where each interval is represented by a
line segment. This experiment investigates the effect of using
different numbers of line segments to approximate the curve.
It is expected that as the number of segments approximating
the curve increases, the accuracy of the simulation increases
(i.e. which yields a better bending behavior). In case the
line segments are being searched linearly, then using a
larger number of segments will increase the time required
to compute the bending force. In this regard, the segments
data can be stored in a hash table to speed up the segments’
search.
Figure 7 shows different numbers of line segments used
to approximate the bending curve influence the bending
behavior. Each row shows the cloth draping behaviour on
a sphere at different time steps. As the number of segments
approximating the curve increases, the cloth’s bending be-
havior gets better. A number of segments as small as 2 makes
cloth sheet behaves similar to a paper sheet. As the number
increases, the bending behavior gets better and closer to the
actual, non-approximated behavior developed by Choi and
Ko [5].
V. CONCLUSION AND FUTURE WORK
In this paper we proposed a fast technique for cloth
simulation. The proposed work extended the physical mass-
spring model technique to speed up its computation by
linearizing the bending function. Results showed that the
proposed technique was almost six times faster than the
traditional technique of directly evaluating the complex
physical models. Results showed the effect of changing
the bending stiffness coefficient on the behavior of cloth.
We conclude from these results that allowing for a large
range for the bending coefficients require decreasing the
time step even with a numerical technique that shows high
stability like Verlet integration. This means that we have to
compromise between the range of bending stiffness (which
enables simulating a larger range of behaviors) and the speed
of the simulation. Textiles with higher stiffness coefficients
should be simulated at smaller time steps. However, the
velocity-less Verlet integration scheme we utilized is still
faster than other integration schemes. The overall proposed
approach can be embedded into an apparel design and
modeling tool or a virtual fitting room module to quickly
and stably simulate clothes.
REFERENCES
[1] J. Barbic and J. Popovic, “Real-time control of physicallybased simulations using gentle forces,” ACM Trans. onGraphics, SIGGRAPH Asia 2008, vol. 27, no. 5, pp. 163:1–163:10, 2008.
[2] M. Bergou, M. Wardetzky, D. Harmon, D. Zorin, and E. Grin-spun, “A quadratic bending model for inextensible surfaces,”in Proc. of the 4th Eurographics symposium on Geometryprocessing, 2006, pp. 227–230.
[3] R. Bridson, S. Marino, and R. Fedkiw, “Simulation of cloth-ing with folds and wrinkles,” in ACM SIGGRAPH 2005Courses, 2005, p. 3.
[4] D. W. Cantrell. (2004) A series for the inverse sinecardinal function. [Online]. Available: http://www.dsprelated.com/showmessage/13099/1.php
105
Figure 4. Simulation results for cloth hanged from 2 points
[5] K.-J. Choi and H.-S. Ko, “Stable but responsive cloth,” inProceedings of the ACM SIGGRAPH, 2002, pp. 604–611.
[6] R. Feynmann, “Modeling the appearance of cloth,” Master’sthesis, Dept of EECS, Massachusetts Inst. of Technology,Cambridge, 1986.
[7] M. Gaber. (2003) Real-time cloth simulation. [Online].Available: http://www.maxgarber.com/projects/cloth/
[8] A. Garg, E. Grinspun, M. Wardetzky, and D. Zorin, “Cubicshells,” in Proc. of the 2007 ACM SIGGRAPH/Eurographicssymposium on Computer animation, 2007, pp. 91–98.
[9] R. Goldenthal, D. Harmon, R. Fattal, M. Bercovier, andE. Grinspun, “Efficient simulation of inextensible cloth,”ACM Transactions on Graphics, vol. 26, no. 3, p. 49, 2007.
[10] T. Jakobsen, “Advanced character physics,” in Proc. GameDevelopers Conference, 2001.
[11] M. K. Kang and J. Lee, “Technical section: A real-timecloth draping simulation algorithm using conjugate harmonicfunctions,” Computers and Graphics, vol. 31, no. 2, pp. 271–279, 2007.
[12] J. Lander. (1999) Cloth simulation using mass andspring system. [Online]. Available: http://www.darwin3d.com/gdm1999.htm
[13] M. C. Lin and S. Gottschalk, “Collision detection betweengeometric models: A survey,” in Proc. of IMA Conference onMathematics of Surfaces, 1998, pp. 37–56.
[14] NVIDIA. (2007) Cloth simulation. [Online]. Avail-able: http://developer.download.nvidia.com/SDK/10/direct3d/Source/Cloth/doc/Cloth.pdf
[15] S. Oh, J. Ahn, and K. Wohn, “Low damped cloth simulation,”The Visual Computer: International Journal of ComputerGraphics, vol. 22, no. 2, pp. 70–79, 2006.
[16] X. Provot, “Deformation constraints in a mass-spring modelto describe rigid cloth behavior,” in Graphics Interface, 1996,pp. 147–154.
[17] B. T. Sewell, “A rapid lookup table method for trigonomet-ric functions,” Software: Practice and Experience, vol. 12,no. 10, pp. 885–887, 1982.
[18] D. Terzopoulos, J. Platt, A. Barr, and K. Fleischer, “Elasticallydeformable models,” in SIGGRAPH ’87: Proceedings of the14th annual conference on Computer graphics and interactivetechniques. New York, NY, USA: ACM, 1987, pp. 205–214.
106
Figure 5. Different behavior of cloth draping on a box for different bending stiffness.
Figure 6. Cloth draping behavior on a sphere for different bending stiffnessKb (0.0, 0.1, 0.3). Each column shows the draping behaviour at differenttime steps
[19] P. Volino and N. Magnenat-Thalmann, “Comparing efficiencyof integration methods for cloth animation,” in Proceedingsof Computer Graphics International (CGI). IEEE Publisher,July 2001, pp. 265–274.
Figure 7. The effect of using different numbers of segments to approximate
the bending curve. The number of segments are 2, 5, and 60 from row1 (top) to row 3. The final row (bottom) shows the results withoutapproximating the bending curve. Each row shows the draping behaviourat different time steps
[20] P. Volino and N. Magnenat Thalmann, “Simple linear bendingstiffness in particle systems,” in Proc. of the 2006 ACM SIG-GRAPH/Eurographics symposium on Computer animation,2006, pp. 101–105.
[21] J. Weil, “The synthesis of cloth objects,” in SIGGRAPH’86: Proceedings of the 13th annual conference on Computergraphics and interactive techniques. New York, NY, USA:ACM, 1986, pp. 49–54.
107