From ActiveWiki
Jump to: navigation, search




The cloth object type allows for realistic cloth-based objects, like flags waving in the wind or making an deformable object.

  • Cloth is a quiete complex topic. Before starting to build, you may want to read at least the tips below. Simulating cloth can be a quite stressing task for your PC. Avoiding a few things and always attempting to build for best performance will help you to create fascinating content in your world using cloth, fabric and deformable objects.

Note, only described features are currently supported. Some more features are already found with cloth properties, that are either greyed out or disabled for now.

Basic Principles of Cloth

(Source: NVIDIA® PhysX® SDK Documentation)


The cloth feature of the NVIDIA® PhysX® SDK allows for simulation of items made from cloth, such as flags, clothing, etc. This is accomplished by providing a mesh that is used to define a set of particles (vertices). The topology of the mesh allows the SDK to construct constraints between the particles that mimic how cloth can bend and stretch. In addition, cloth particles can be pinned to shapes and global positions, such as attaching a flag to a pole.


There are two main types of cloth constraints:

  • Stretching - applied to maintain distance between each particle that is connected by an edge in a cloth mesh. The strength of this constraint is assigned using the SDK; specifying a small stretching constraint factor allows the particles to move apart more easily and gives the impression of more stretchy cloth, such as lycra. Specifying a larger constraint factor makes the cloth stiffer, like denim.
  • Bending - applied to maintain the angle along an edge in a cloth mesh, either by constraining the angle directly or by constraining the distance between the pair of particles on either side of the edge (see the diagram below). An example of a material that would use a low bending constraint for simulation is cotton, while a substance such as paper or cardboard would use a high bending constraint.

Cloth Attributes

(in alphabetical order)

Attachment Response Coefficient

This coefficient controls the strength of the momentum transfer between a cloth and the shape(s) it is attached to. A large attachment response coefficient will cause the cloth to pull/push the body more easily and a lower value will mean the rigid body is more difficult to move.

Defines a factor for the impulse transfer from cloth to attached rigid bodies. Only has an effect if the attachment response is checkmarked and the cloth is attached to a rigid body.

Default: 0.5 Range: [0,1]

Attachment Tear Factor

If the Attachment Tearable is checkmarked, this variable defines the elongation factor that causes the attachment to tear.

Must be larger than 1. Only has an effect if the attachment tearable is checkmarked and the cloth is attached to a rigid body.

Default: 1.0 Range: [1,1000]

Bending Stiffness

Bending stiffness of the cloth in the range 0 to 1.

Default: 1.0 Range: [0,1]

Collision Response Coefficient

The collision response coefficient is similar to the attachment response coefficient, except instead of applying forces due to the attachment, it applies forces due to collision.

Defines a factor for the impulse transfer from cloth to colliding rigid bodies. Only has an effect if Collision Response is checkmarked.

Default: 0.5 Range: [0,1000]

Compression Limit

Defines a factor up to which the cloth is weak under compression. This factor is the lower part of a range [limit, 1]. Whenever an edge is compressed to something between [limit, 1] * original length, the stretchingStiffness is multiplied with the compressionStiffness.

Since the compressionStiffness is smaller or equal to 1, this will always define a range where the cloth reacts more softly to compressed edges. This feature is useful to generate small wrinkles features on the cloth mesh outside the SDK.

Default: 1.0 Range: [0, 1]

Compression Stiffness

Defines the stiffness of the cloth under compression. This stiffness scales the Stretching Stiffness in the range defined by Compression Limit.

Default: 1.0 Range: [0, 1]

Damping Coefficient

Controls how much damping is applied to the motion of cloth particles. Damping is always performed for the velocity of each individual particle. If Global Pos Damping is checkmarked, the global rigid body modes (translation and rotation) are exempted from damping. If not, the global translation and rotation of the cloth are damped, same as the internal movement of the cloth.

Spring damping of the cloth in the range 0 to 1. Useful to reduce CPU/GPU load, and for putting cloth asleep.

Default: 0.1 Range: [0,1]


Density indirectly specifies the mass of the cloth particles. The mass of a particle is calculated as the sum of the following equation (for triangles sharing a point):

1/3 * triangleArea * density

Default: 1.0 Range: [0,1000]


Friction coefficient in the range 0 to 1. Defines the damping of the velocities of cloth particles that are in contact.

Default: 0.5 Range: [0,1]

Hard Stretch Limitation Factor

Defines the hard stretch elongation limit. If Hard Strech Limit is checkmarked, the solver pulls vertices with a maxDistance greater zero towards vertices with maxDistance zero (attached). This reduces the stretchiness even for low solver iteration counts. The process is non-physical and can yield small ghost forces. The Hard Stretch Limitation Factor defines by what factor the cloth is allowed to stretch.

Default: 1.0 Range: [0,1000]

Min Adhere Velocity

If Enable Adhere is checkmarked, the cloth moves partially in the frame of the attached actor. This feature is useful when the cloth is attached to a fast moving character. In that case the cloth adheres to the shape it is attached to while only velocities below the parameter Min Adhere Velocity are used for secondary effects.

Default: 1.0 Range: [0,1000]


If pressure is set to another value than 0, this variable defines the volume of air inside the mesh as volume = pressure * restVolume. For pressure < 1 the mesh contracts w.r.t. the rest shape For pressure > 1 the mesh expands w.r.t. the rest shape

Default: 0.0 Range: [0,10]

Stretching Stiffness

Stretching stiffness defines the strength of the constraint along a triangle edge that maintains the distance between the edge end points. A value of one will produce a cloth that is very difficult to stretch, such as denim pants, while a value near zero will produce one that can stretch easily, like nylon stockings (a value too near zero is not recommended for a stable simulation; zero is not allowed).

Stretching stiffness of the cloth in the range 0 to 1. Note: stretching stiffness must be larger than 0.

Default: 0.5 Range: [0,1]

Tear Factor

If tearing is enabled, this variable defines the elongation factor that causes the cloth to tear. Must be larger than 1.

Default: 2.0 Range: [1,1000]


Thickness of the cloth. The thickness is usually a fraction of the overall extent of the cloth and should not be set to a value greater than that. A good value is the maximal distance between two adjacent cloth particles in their rest pose. Visual artifacts or collision problems may appear if the thickness is too small.

Thickness defines the triangle's level of thickness for collision detection, improving its robustness. Setting the thickness very low is not recommended as this will lead to poor collision handling.

Default: 0.5 Range: [0,1]

Valid Bounds

By using valid bounds you can specify an axis-aligned bounding volume to which the cloth is restricted. Any part of the cloth that leaves this volume (such as pieces torn off an otherwise attached flag) will be removed from the simulation.

If the bounds are set, this variable defines the volume outside of which cloth particle are automatically removed from the simulation. The values for x, y, z each define a distance from the current position in world in positive and netagive directions.

Default: 0 Range: [0,1000]


As with external acceleration this applies an acceleration on each vertex. However this acceleration is only applied in the vertex normal direction, i.e. only the component of the external force that lies in the direction of the vertex normal is applied to the vertex. This makes it easy to simulate effects such as wind.

Wind is an acceleration (unit length / s^2) which acts normal to the cloth surface at each vertex.

Default: (0,0,0)


General tips (basic rules)

  • Do not intersect cloth with static colliders. This causes odd behavior of the cloth and adds lots of CPU/GPU load (10 times more!) onto the PC.
  • Look at the yellow bounding box of rigid body objects that you want to collide with cloth or any other rigid body. If the shape matches the size of the bounding box, use primitives like box, sphere or capsule. Do not use cylinder for static shapes. If the shape of the object does not match the bounding box, i.e. the bounding box is much bigger than the object's geometry, use a hull (convex mesh) for dynamic rigid bodies and tree (triangle mesh) for static rigid bodies.
  • Models with very irregular order of triangles, as well models with many clumps (submeshes) will not work well for used for cloth objects.
  • Geometry with less or equal 3 verticies, or less than 2 triangles will be rejected.

How to create stiff cloth

  • Use fewer vertices (fewer vertices makes stiffer cloth).
  • Use higher iteration counts (associated performance impact).
  • Use Ortho Bendning mode (results in stiffer, more realistic cloth bending).

How to improve cloth performance

  • Use fewer vertices, a lower resolution.
  • Use simple bending constraints (Bending Stiffness only and not Ortho Bending).
  • Disable cloths that are not relevant using Static (checkmark static).
  • Disable tearing for cloths which do not need tearing (uncheck tearing).
  • Avoid cloth self collision (uncheck Selfcollision).
  • Avoid cloth intersecting with static colliders.

How to use pressure

  • If the pressure is set to a value less than 1.0 (the default), the pressure will be insufficient to preserve the initial shape of the cloth and it will collapse until it has been compressed enough to have an internal pressure of 1.0.
  • If the pressure is set to a value greater than 1.0, the cloth will expand beyond its initial size; how much will depend on the stretching stiffness of the cloth.
  • Pressure only works well on closed geometries. If pressure is applied to flat panels or objects like trees, you may experience unexpected events.