In this projet you will create a simulation of cloth. The cloth will be just a subdivided plane.
You will use a Compute Shader to update the positions and velocities of the vertices of the cloth. Your simulation will have to detect collisions between the cloth and a sphere and make the cloth react in a realistic way.
The cloth geometry and the springs connectivity will be generated on the CPU. The simulation must run on the GPU with a Compute Shader. Simulations parameters must come from the CPU code via Bind Groups.
The project will have to be defended during the oral exam in January.
In a cloth simulation, only the motion of individual vertices is
calculated. Each vertex is considered as a point body with a mass, a
position and a velocity. At each time step, we calculate the forces that
apply on the vertex. The resultant of the forces allows us to calculate
the acceleration. The acceleration allows us to update the velocity. The
velocity allows us to update the position.
Where
and
are respectively the positions in the current frame and in the previous
frame. Idem for
and
that are velocities.
is the resultant of the forces and
the mass.
is the time step. If we want a stable simulation we will need to compute
multiple time steps between each frame. What are the
forces that apply in a simulation of a cloth? To make a simple
simulation, we consider that the different vertices of the cloth are
connected by springs. The forces are easily calculated using Hooke’s
law.
Where
is the spring stiffness constant and
the difference in length compared to the length of the spring at rest.
the
sign is there to remind us that the force opposes the length variation
and therefore acts to bring the spring back to its rest length.
To obtain a realistic behavior it is necessary to have three types of springs in a cloth.
The stiffness constants of these three types of springs are generally different.
The problem with springs is that they have an annoying tendency to
oscillate. To reduce this problem, a damping force is added. This force
resists the movement of the spring and is proportional to the extension
rate.
Where
is the damping coefficient.
For the cloth to fall, gravity must obviously be taken into account.
The contact with the sphere will also be modelised by an elastic
force:
Where
is the penetration depth and
the stiffness of collisions.
During the contact between the cloth and the sphere, it is possible to take into account frictional forces. The friction is tangent to the friction surface and is calculated on the basis of the resultant of the other forces.
Where
is the resultant of the other forces.
et
are its tangential and normal components.
is the unit vector normal to the surface.
is the unit vector tangent to the surface in the same direction as
.
is the coefficient of friction. In short, the frictional force cancels
out the tangential component of the other forces up to a certain point
which depends on the normal component.