Saturday, 31 January 2009

Implementation : Next Steps

With the first basic implementation completed i'm now thinking of what directions to take to improve the simulation. My thoughts are as follows:
  1. Add a user-controlled wind force that allows interactivity and better demonstrates the cloths behaviour.
  2. Add in collisions with spheres and cubes.
  3. Add Deformation contraints. Reduce the rubbery and bounceyness of the cloth.
  4. Improve stability. Allow for higher resolution cloth.
  5. Get the cloth behaving more realistically by experimenting with the spring and damping coefficients of the stretch, shear and bend springs. Also tinker with the global damping constant.
  6. Improve efficiency. Shoot for the highest frame rate you can get. Maybe profile code to find what parts are most expensive.

Thursday, 29 January 2009

X.Provot - "Deformation Constraints in a Mass-spring Model to Describe Rigid Cloth Behaviour" (1995)

This paper looks at modelling cloth from a system of point masses connected by "springs".

The system is made of three types of springs:
  • Structural
  • Shear
  • Flexion (bending)



The diagram above shows how these springs are arranged. Structural springs hold the cloth together, shear springs resist shearing deformations (movement in the plane of the cloth), and flexion (bend) springs resist bending (movement outside the plane of the cloth).

Each point-mass and its connected springs contribute to the overall behaviour but each point-mass and spring can be treated completely independently.

The movement of each point mass is determined through numerical integration of newtons second law (F=ma).

The force acting on each point-mass is broken down into internal and external forces. The internal force is evaluated as the sum of the tensions coming from each spring associated with the mass. External forces can be added to interact with the cloth, those noted are a gravitational force, a damping force (to simulate the natural loss of energy in the system) and a viscous interaction from a fluid (used to inflict wind).

With the force on each point-mass calculated, the acceleration is computed simply using a=F/m.

Then the simple Euler numerical integration scheme is noted as their method to solving velocity and position.

The original results showed a square sheet of cloth hanging from two corners, where the deformation of the springs close to the corners was very high and the deformation elsewhere was relatively low.

This behaviour is suited to a sheet of elastic but such local deformations would not occur in woven fabrics. According to the paper, cloth under high loads is inclined to rip before any large deformations occur.

Fabrics are far from ideally elastic materials. You would clearly notice the difference in behaviour between a sheet of fabric and a sheet of rubber -- rubber behaving predominantly elastically and the fabric behaving somewhat more stiffly, depending on the type of fabric. The differences between the behaviour of these two materials are most obvious in intense deformation. However, since many scenarios do not cause intense deformation (such as a table cloth), cloth is often modelled ellastically.

It is also noted that the initial results showed unrealistically high amplitude oscillation because of the elastic modelling. This was countered by a large damping force, but lead to other shortcomings where the cloth looked like it was immersed in thick fluid.

The obvious way to increase the stiffness and reduce the elasticity of the model is increase the stiffness of the springs. This can be done but reducing the time-step is required to ensure the simulation remains stable. Decreasing the time-step means more computation, resulting in a more costly algorithm.

To avoid this loss in inefficiency, Provot increases the stiffness of the cloth by constraining the amount cloth can deform. He limits the amount each spring can stretch from it's rest length. The
stretch of each spring is compared with a threshold value; if it is larger, the ends of the spring are brought closer together so that the threshold is met. This gave more realistic cloth deformations, where it would propagate through the structure as the constraints were enforced -- as apposed to staying in a concentrated area. This gave much more realistic and less elastic looking cloth, whilst maintaining the efficiency of the algorithm. However there is the overhead of constraining. Provot estimates it to be 15% greater computation than the classic elastic model.

Note that the deformation constraints could be applied to the different types of springs. Provot constrained the structural and shear springs because this is where cloth resists deformation most. He did not constrain the flexion (bend) springs, because cloth is generally accepting of bending motion. It was found in the results that cloth would bend to find it's "rest state" as apposed to stretch or sheer -- this is what real cloth will do.

Provot also notices taking a two-pass approach, where each spring is constrained twice, yields even better results -- as if the procedure is converging to a more accurate result. So the algorithm could be adaptive in terms of accuracy and efficiency, where multiple passes give accurate results and less passes give fast efficient results.


The results Provot showed were a hanging sheet of cloth, a flag blowing in a strong wind,and boat sail with wind blowing through it. Simulation times are said to be in the order of minutes.

Wednesday, 28 January 2009

First Implementation

Features for first implementation:-
  • Particle-System based
  • Mass-Spring model (X.Provot style)
  • Euler Integrator
  • Basic Gravity Force
  • Fixable Points
Essentially this boils down to being the most simple cloth simulation you can build.

I am already somewhat familiar with particle systems from second year so thats why i chose this approach. To me, they are easier to understand than some of the more complex models out there.

Additionally the mass-spring model is well documented. I have found articles regarding the model on the internet in addition to X.Provot's paper, which describes it in-depth.

The Euler integration is the easiest to implement and the easiest to understand. This will be abstracted from the particle system so that other more advanced integration methods can be plugged in later.

The gravity force and fixable points are there to give a good indication of whether the cloth is behaving as it "should" be. They will alow me to see the "draping" behaviour.


------------ RESULTS --------------

  • Experiencing the issue described in Provot's paper, refered to as "Super-elasticity".
    As a result cloth looks rubbery and is "bouncey".
    Could apply Provot's spring deformation constraints in to improve.
  • Higher resolution appears to decrease stability -- more springs, thus more energy in the cloth , thus a more stiff system and more prone to "blowing up".
  • Decreasing the time-step improves stability.
  • Played around with the spring coefficients a bit, unsure of which springs should be strongest and which should be weakest (bend stretch or shear?).

A comman interface for all types of force is proving difficult to create.
  • Spring forces depend on two particle positions.
  • Gravity force is constant and acts on every particle.
  • Damping force is applicable to all particles but depends on the particle it is being applied to(inversely proportional to velocity).
Currently Particle system contains a number of spring forces and gravity and drag forces are hardcoded in.

Thursday, 8 January 2009

D.Breen - "A Particle-Based Model for Simulating the Draping Behaviour of Woven Cloth" (1993)

This paper set out to produce simulations of the various "draping" behaviours in a range of woven fabric types.
http://www.speed-light.info/speed_of_light/speed_of_light_weave.jpg
This paper very much acknowledges the underlying structure of what we refer to when we talk about cloth - we are refering to a complex woven material that contains thousands of fibres of "warp" and "weft" threads.

It poses questions such as "what would this shirt look like if made from polyester instead of cotton?"

This paper claims it is the first of its kind to attempt to simulate a specific type of fabric.

-------------------------

The model is based on interacting particles.

Emperical data from the well-known Kawabata fabric analysis system is used to tweak the model to exhibit realistic draping bahviour of particular fabrics.

It is noted that different fabric behaviours depend on lots of factors including the type of fibre (silk, cotton, polyester ect), the weight of the yarn and the tighness of the weave.
http://frobmob.org/aerial/tests/ptest2007/ft300fu/weave_front.jpg
The approach taken attempts to model the low-level microscopic interactions of the fabric in belief that the correct macroscopic higher-level features will manifest themselves.

As mentioned earlier the complex composition of fabric and how this effects its "draping behaviour" is considered in this model, meaning cloth is not simply considered a continuous sheet.

However, it says that to completely model all the interactions of thousands of fibres is simply too computationally expensive and thus an undesirable approach.
So a happy medium is obtained where complexity is aknowledged such that the most important interactions of cloth can be modelled.

Energy of the cloth is modelled and broken down into repulsion energy, stretch energy, bend energy, trellising energy and gravitational energy. The methods by which these are evaluated are discussed in the paper.

It reports that the "bend" and "trellising" energies are the most significant contributors to the draping behaviour of the cloth and that using their inital configuration, they were not able to convincingly simulate different types of cloth.

So thats why Breen moved to the Kawabata system to "tweak" his model from empirical data.


http://www.geocities.com/SiliconValley/Heights/5445/kawabata.gif

Simulation times are reported as being on the scale of days! One particular simulation is quoted as having taken 1 CPU-week on an IBM RS/6000 workstation!

While this hardware is nothing compared with what we have available to us now, the method clearly has efficiency issues (which are acknowleged in the paper), especially when considering simulating cloth for real-time applications at 30 frames-per-second.

Wednesday, 7 January 2009

P.Volino - "Versatile and Efficient Techniques for Simulating Cloth and Other Deformable Objects" (1995)

Why this paper?
This paper attempts to model deformable objects for general applications with less restrictions apparent than in previous models.

It looks at a more efficient collision detection and handling process, that is universally suitable for all kinds of collisions with a surface (and handles many consecutive collisions).
The process described handles self-collision very efficiently.

It highlights the difficulties of collision handling in generic situations; that possible optimizations based on a known predifined contex do not apply.


How is cloth represented?
The paper states the underlying representation they will use will be a particle system, where each particle represents a vertex of a triangle (where triangles share vertices and therefore particles too).

Cloth is considered to be isotropic material (meaning it's properties are independant of the direction in which they are measured) and of constant thickness.


What are the "Driving Equations" of the cloth?
Deformable surfaces are simulated through Integration of newtons motion equation, keeping time-steps as small as possible. It says that other more complex methods (energy minimization, lagrange dynamics) allow larger time-steps, but since the collision detection algorithm will require small time-steps to be effective these methods are ignored.

The numerical integration method used to solve the equations is the second order (midpoint method) of the Euler-Cromer method (also known as the semi-implicit Euler method). An adaptive time-step scheme is incorporated into this routine, giving optimal efficiency whilst maintaining accurate results.

Buckling, due to cloth compression, is considered into the Elastic properties that model the cloth (Young's modulus, Poisson coefficient, density and thickness) by allowing the Young's modulus to vary, depending on whether the cloth is stretched or compressed.

Cloths ability to move past positions from which it will no longer return (like a spring going beyond it's elastic limit) is handled by changing the inital conditions of the differential equations to the current conditions when a deformation exceeds a certain amount.

Curvature forces are evaluated by looking at the "hinges" (sharing edges) of triangles and using the angle between the normals.

Strain within the cloth is calculated from the strain at each edge of each triangle.

Contraints caused by collisions are satisfied iteratively.


How are collisions with the cloth handled (if at all)?
Collisions are handled as a seperate process. Cloth is simulated, then collision detection is ran and then the neccessary collision handling is taken care of.
To increase efficiency, an algorithm based on hierarchical octree subdivision singles-out the potentially colliding elements at any one time. It takes advantage of adjacency between elements in a heirarchy, which is built once during preprocessing. The criteria for which elements should be "collision checked" is based on a calculated property "surface curvature". The surface curvature property is also used to cut-down the self-collision tests.


Any results or conclusions of interest?
A simulation was run on pieces of cloth within a rotating cylinder to animate them the way a drying machine would. This was a good test of the robustness of the collision detection algorithm, since many collision configurations occur, and interactions of cloth-to-cloth and solid-to-cloth are frequent. It is also a good test for the collision response procedure and the overal numerical stability of the model.


Additional Sources:

http://www.thefreedictionary.com/isotropic
http://en.wikipedia.org/wiki/Young%27s_modulus
http://en.wikipedia.org/wiki/Symplectic_Euler_method

Friday, 2 January 2009

C.Feynman - "Modelling the Appearance of Cloth" (1986)

Why this paper?
This was the first paper pointed to by the Survey Paper that looks at physically modelling cloth. From 1986, it is also probably one of the first written on the topic.


How is cloth represented?
In this paper, Feynman represents cloth as a discrete, uniform grid of points. A "multi-grid method" is used, where multiple grids of varied densities are used to represent cloth; see below.
Cloth is modelled such that each point represents a piece of cloth sized h*h (where h is the distance between points) The behaviour of a point is governed only by its nearest neighbours, thus two points on opposite sides of the cloth have no impact on each other.


What are the "Driving Equations" behind the cloth?
Cloth is simulated by minimizing its energy state. This is also known as relaxation. The sum of the energies at each point equals the energy state of the entire cloth.

Each point is relaxed one-by-one. Each point in the grid is relaxed by evaluating a "force vector" that will move the point into a position of decreased energy. When this is done for all points, the overall energy state of the cloth is decreased.

Feynman derives and equation to evaluate the energy state of the cloth from the theory of elastic plates. This equation attempts to mimic the energy dynamics of cloth in "real-life". In his approximation, the total energy is a combination of gravitational effects, bend effects and strain effects. (Strain being distortion within the plane of the cloth, and bend being distortion outside the plane.)

The multi-grid method is an optimization based on the premise that creating large features (large folds ect) through relaxation on a fine grid is more costly than on a coarse grid. In fact there is an optimal grid size (point-spacing) for a feature of a certain size, so that it is small enough to represent to the feature but coarse enough that as few as possible points have to be relaxed.

The idea behind the multi-grid method then, is that multiple relaxation sweeps are done for grids of multiple resolutions -- finer grids for small features and coarser grids for larger features. Finally results from these relaxation sweeps are molded together, incorporating both the small and large features into one grid.


How are collisions with the cloth handled (if at all)?
Feynman included support for collisions with ellipsoids. Ellipsoids can be used to represent a wide range of solid objects, whilst can be algebraically defined easily (although Feynman admits the collision detection is still a slow process). He defines a collision as one or more points being inside the volume of the ellipsoid. A collision is handled by placing the point back at the nearest point outside of the ellipsoid.

Feynman comments that the results involving collisions are disappointing and highlights that when the cloth grid is too coarse it is possible for solid objects to completely pass through the cloth without a collision even being detected.


Any results or conclusions of interest?
Feynman simulated environments with hanging clothes and cloth draped over a sphere.
But no results regarding the time taken to run these simulations were given.
Note that this paper produced static results not animated ones. Feynman discusses the difficulty of using the energy minimization approach to a dynamic simulation. Since one of my "requirements" is that my simulation is dynamic, perhaps, as Feynman advises, the energy minimization technique would not be the best approach for me to take.

An interesting observation that Feynman highlights was the difference between stretching and compressing cloth, and the different way it responds to these actions. He explains how cloth is strong when it comes to resisting stretching but weak at resisting compression because of buckling. When you attempt to compress cloth, the fabric itself will most likely not give, but it will buckle instead (bend out of it's plane). Although mentioned, buckling is not a phenomenon taken care of in this work.

Another behavioural property of cloth highlighted is cloth's tendency to arrange itself in positions it has previously been in (particularly for long periods of time). This is due to prolonged arrangement of fibres in cloth and the friction between them. This phenomenon was also unaccounted for.