Game Development Reference
In-Depth Information
12.3 Modeling Real Fabrics
Unmodified, the simulation technique outlined so far produces clothing that looks
like a light rubbery silk. Fashionistas typically turn up their noses at such attire,
while gamers dream of the comfort such clothing would bestow upon the wearer.
Gamers desire to play neither a comfortable gamer nor a fashionista during their
gaming sessions. Therefore, this fabric is irrelevant, and we must try to improve
the visual appeal.
The application of internal damping helps make the cloth look like it is made
of a more natural material. This is done by projecting the particle velocities
on the distance constraints.
For the best effect,
it can be applied every
iteration.
Vector3 paPrev = constraint.m particleA.previousPosition;
Vector3 pbPrev = constraint.m particleB.previousPosition;
float dampingFactor = 0.3f;
Vector3 va = pa
paPrev;
Vector3 vb = pb pbPrev;
Vector3 vab = va
vb;
Vector3 v = vab.dot( dp );
float damping = v dampingFactor;
pa += dp 0.5 damping;
pb =dp 0.5 damping;
There is a performance cost here, but the improvement to the visual quality of
the material is significant.
Real fabrics buckle much more easily in comparison to their resistance to
stretching. Ideally, this would be modeled by using a very high-resolution set
of particles. Even then a stiff buckling resistance will be present, although at a
higher frequency and less noticeable scale.
An alternative is to weaken the constraints' resistance to compression up to a
certain limit. This also helps alleviate the jagged bunching and jittering of cloth
that can occur at character joints. Visually we lose some creasing and folding,
but the motion looks more convincing. As an example, around the shoulder joint
of a character, we will most likely see popping and jagged cloth mesh artifacts.
To fix this problem, we can tune the constraints in this area to not respond to
compression: