Skip to main content
Version: Next (dev)

Character Cloth

Character cloth simulates the garments of an animated character: capes, coats, skirts, scarves and anything else that is skinned to the skeleton but should swing, drape and react to wind. Every point of the garment may move a painted distance away from where skinning puts it and no further, so the cloth always stays with the character, even in a sprint, a spin or a teleport.

Character cloth is different from the older Cloth Sheet component, which simulates a free-hanging square patch such as a flag and does not follow a skeleton.

Requirements​

  • The plasma.jolt package with character cloth support. The cloth asset, the Cloth window and the components come from that package; releases up to and including 1.3.2 do not have them. See Packages.
  • An engine with the cloth stage in compute mesh deformation (after 0.12.0). The engine skins the garment, applies the simulated positions on the GPU and keeps the previous frame's positions, so simulated cloth gets correct motion vectors for motion blur and temporal anti-aliasing.
  • An animated mesh with a skeleton. Static meshes cannot carry garments.

How it fits together​

PieceWhat it does
Garment in the model fileA mesh whose name starts with CLOTH_, skinned like the rest of the character. Imported as part of the animated mesh.
Proxy in the model file (optional)A coarser mesh named CLOTHPROXY_<same name>. It is simulated in place of the garment and never drawn; the garment follows it.
Cloth assetCooks the garments of one animated mesh: fabric, painted maps, body colliders, simulation rate and distances. Edited in the Cloth window.
Character Cloth (Jolt) componentSits next to the Animated Mesh component in the scene and simulates the garments at runtime.
Bone Chains (Jolt) componentLets chains of joints (ponytail, straps, pouches, tails) swing on top of the animation. It can also stand in for a garment when that garment is not simulated.

From the model file to a simulated garment​

1. Name the garments in your modelling tool​

The importer looks at mesh and object (node) names. Most modelling tools export object names as node names, and either works.

  • CLOTH_<Name> marks a garment, for example CLOTH_Cape. It is drawn and skinned like any other part of the character, and it can be simulated.
  • CLOTHPROXY_<Name> marks a simulation proxy for the garment with the same <Name>, for example CLOTHPROXY_Cape for CLOTH_Cape. The proxy is never drawn. Use one when the render mesh is dense: the simulation then runs on the proxy and the render mesh follows it. A garment may have at most 65,536 simulated points; above that the cook fails and asks for a proxy.

The prefixes are not case-sensitive. Garments are only read from skinned meshes: give the garment and its proxy skin weights, usually copied from the body under them.

Garments do not take morph targets. A garment that has blend shapes imports without them and the import log warns about it.

2. Paint the masks into vertex colours (optional)​

The first vertex colour set of a garment or proxy carries three masks. You can paint them in your modelling tool, or later in the Cloth window.

ChannelMaskMeaning
RedPin1 keeps the point on its skinned position, 0 lets it move the full Max Distance. Paint the collar of a cape or the waistband of a skirt red.
GreenBackstopScales the Backstop Distance: how far the point may move inward, into the body.
BlueStiffnessScales the stiffness of the fabric at that point. Never softer than 5 % of the fabric.

A channel that has the same value on every vertex counts as unpainted, and the asset's default applies. A garment without vertex colours is free everywhere until you pin it, for example with Auto Mask in the Cloth window.

3. Import the animated mesh​

Import the file as an animated mesh as usual. Garments and proxies are picked up automatically; there is no option to set.

4. Create the cloth asset​

Select the animated mesh in the asset browser, right-click it and choose Create Cloth, or press Create Cloth in the toolbar of the animated mesh's own window. Either one makes a cloth asset with the same name next to the mesh, sets its Mesh and opens it in the Cloth window.

5. Tune it in the Cloth window​

Pick a Fabric Preset, paint where the garment is pinned, check the body colliders and play a clip on the character. Run the Stress Test before you ship it. See Cloth Asset.

6. Add the component in the scene​

When you save the cloth asset, the editor lists the scenes and prefabs that draw the mesh without its cloth and offers to add a Character Cloth (Jolt) component next to the Animated Mesh component in each. Answer Yes, or add the component yourself: select the object with the Animated Mesh component, add Physics > Jolt > Animation > Character Cloth (Jolt) and set its Cloth.

The cloth simulates in Play mode and in the Player. Use Project > Packages > Jolt > Cloth View in the scene to see the state of every garment.

Performance and level of detail​

Garments step on worker threads, after the pose of the frame is known. How many garments simulate is limited:

  • By distance. A garment steps every frame up to the asset's Full Rate Distance (14 m), at half rate beyond it, and is plain skinned beyond Simulate Distance (30 m). Between simulated and skinned it fades, so nothing pops.
  • By visibility. A garment that leaves the screen keeps simulating for about a second and then stops.
  • By budget. Each quality tier allows a number of garments at once. The nearest garments with the highest Importance get the budget; the rest are drawn skinned. Garments with Importance set to Always Simulate always step at full rate and do not count against the budget. Use that for the player character.
CVarDefaultDescription
Jolt.Cloth.EnableonSimulate character cloth. Off draws every garment skinned.
Jolt.Cloth.ParallelonStep garments on worker threads.
Jolt.Cloth.MaxSimulatedGarments-1Garments that may simulate at once, whatever the quality tier. -1 takes the budget of the active tier.
Jolt.Cloth.Budget.Low4Budget in the Low quality tier. Negative means no limit.
Jolt.Cloth.Budget.Medium8Budget in the Medium tier, and wherever no tier is known.
Jolt.Cloth.Budget.High12Budget in the High tier.
Jolt.Cloth.Budget.Max24Budget in the Max tier.
Jolt.Cloth.Budget.Mobile2Budget in the Mobile tier.
Jolt.Cloth.View0Debug view drawn over every garment: 0 off, 1 Sim Mesh, 2 Max Distance, 3 Backstop, 4 Colliders, 5 Strain, 6 State, 7 Cost.
Jolt.BoneChain.VisualizeoffDraws the simulated bone chains.

The tier comes from the active quality preset. A project sets its own budgets in RuntimeConfigs/CVars.cfg.

For a large crowd, give distant or minor characters a Bone Chains (Jolt) component with Stand In For Cloth enabled: their garments swing on a few joints for a fraction of the cost whenever the cloth itself is out of budget.

Troubleshooting​

ProblemCause and fix
The cloth asset fails with "The mesh has no cloth piece to build from"No mesh in the file starts with CLOTH_, or the garment has no skin weights. Rename the object in the modelling tool, give it weights and re-import the animated mesh.
"The cloth would have N particles, the limit is 65536"The garment is too dense to simulate. Add a CLOTHPROXY_ mesh with the same name suffix, or raise Weld Distance a little.
The garment hangs stiffly and never movesEvery point is pinned: the red channel of its vertex colours is 1 everywhere, or Max Distance is 0. Paint the max distance map in the Cloth window, or use Auto Mask.
The garment falls off or sags to the floorNothing is pinned. Paint the top of the garment red (or use Auto Mask) so that it stays at its skinned position there.
Cloth goes through the legs or the bodyThe body has no collider there. Use Auto Select Colliders or Fit From Skin in the Cloth window and check the Colliders view; raise Backstop Distance for tight garments.
The cloth stretches like rubber in a sprintLower Stretch Limit in the cloth asset, keep Tethers on, or lower the component's Linear Inertia.
The cloth settles visibly after a camera cut or respawnCall Reset() on the component after the cut. Moves longer than Teleport Distance reset the cloth by themselves.
Some characters' garments do not moveThey are beyond Simulate Distance, off screen, or out of budget. Check Cloth View > State and the Jolt.Cloth.Budget.* cvars, or set Importance higher.

See Also​

In this section​