top of page

REAL-TIME CLOTH SIMULATION

As part of my coursework for Technical Animation (CMU 15-664),  I simulated cloth behavior from scratch in Unity using C#.

I achieved this  using the Verlet Integration method as described in the paper Advanced Character Physics by Thomas Jakobsen.

Got it to run at around 50 fps. Most GIF examples below have been sped up for the presentation.

Sim_00_Basic.gif
  • [above] Basic example of the cloth moving under gravity.

  • The demo runs at around 50 fps real time

Sim_00_Collision_0.gif
  • [above] Cloth moves under gravity, collides with sphere and slips down

  • Used Rigidbodies in Unity to detect the collision; applied force at the point of contact perpendicular to the plane of contact

Sim_00_Collision_1.gif
  • [above] Forcible collision of the sphere with the cloth still under gravity

  • Cloth recovers its shape

Sim_00_Collision_2.gif
  • [above] Another forcible collision of the sphere with the cloth still under gravity

Sim_00_Collision_3.gif
  • [above] If you too fast with the collision, sometimes the sphere goes through the cloth, and things go haywire.

Sim_00_Collision_4.gif
  • [above] Collision with a differently shaped object - a cube

Sim_00_Collision_5_Cube0.gif
  • [above] Ramming the cube into the cloth, which recovers shape

Sim_00_Collision_5_Cube1.gif
  • [above] Again, sometimes the cube goes through if the action is done too fast

Sim_00_Collision_7_Floor0.gif
  • [above] Contact with ground; the two pinned particles are unpinned at some point.

Sim_00_Collision_8_Floor1.gif
  • [above] Cloth falls on sphere, the ground and slips down under gravity

Sim_00_Collision_9_MorePart.gif
  • [above] Increased the number of particles from 100 to 400 in this one. The result was considerably slower.

Sim_00_Collision_9_SelfColl.gif
  • [above] Tried to make the cloth collide with itself

  • The Rigidbodies help with collisions among particles

Sim_00_Collision_10_Stiffness.gif
  • [above] Increased the stiffness from 0.5 to 1

  • Some particles are a little off

Sim_00_Collision_11_Timestep.gif
  • [above] Increased the time step value

  • The cloth sags a little more

Sim_00_Collision_12_One_Iter.gif
  • [above] Reduced the number of iterations form 15 to 1

Sim_00_Wind.gif
  • [above] Cloth acting under wind forces; stopped gravity for this one.

Some Notes:

  • Used a procedurally generated mesh in unity

  • Vertices are updated every frame and 

  • Timestep of 0.025

  • Iteration count kept at 15

  • All particles assumed to be of mass 1

  • Stiffness value for particles used as 0.5

bottom of page