A simulated cape clips into the hero's legs and through its own folds during a sprint; how do you diagnose and fix cloth collision and self-collision?
answer
- cloth has no thickness by default
- body proxies, not the render mesh
- move less than thickness per substep
- radius against rest spacing
- remember which side it was on
basics
~20 sGive the cloth a collision thickness, collide it against simple body proxies moved smoothly across substeps, keep each particle's travel per substep below that thickness, and test self-collision only between nearby particles that are not neighbours in the rest pose.
solid answer
~40 sFirst find what is passing through what. If the cape enters the legs, check the colliders: cloth should collide against capsules or spheres on the skeleton, and if those jump from the old pose to the new pose in one go, every substep tests against the wrong place, so interpolate them across substeps. Then check travel: a particle moving farther per substep than the collision thickness can skip the surface, so add substeps or clamp velocity. For folds passing through each other, give particles a self-collision radius below half the rest spacing, find nearby pairs with a spatial hash, and skip pairs that are close in the rest pose. Once cloth has crossed itself, a discrete test pushes it out the wrong side, so remember each pair's side from the last valid state.
go deeper
Recall that cloth collides against simple shapes on the skeleton and needs a small thickness so it can be kept off the body.
Explain the collision inequality constraint, why particle travel per substep must stay below thickness, and why self-collision skips neighbouring particles.
Diagnose clipping by symptom: proxy pose not interpolated across substeps, travel exceeding thickness, radius set against spacing, and wrong-side pushes after a tangle.
Decide where to spend cost: substeps, proxy count, self-collision only on hero cloth, and which assets may tolerate rare clipping in exchange for budget.
## Why cloth is hard to collide Cloth is a surface with no thickness. Its particles move fast relative to their spacing, every particle can touch something, and both sides of the sheet can be hit. A discrete collision test only sees where things are at one instant, so anything that moves more than a thin margin per step can end on the wrong side without ever being seen inside. Two separate problems hide behind "the cape clips": - **body collision**, the cloth passing into the character or the world; - **self-collision**, one part of the cloth passing through another. They have different causes, so diagnose them separately: freeze the animation and step the simulation frame by frame, and draw the collision proxies and particle radii. | Symptom | Likely cause | Fix | |---|---|---| | cape enters legs only at sprint speed | proxies jump a whole frame per update | interpolate proxies per substep | | cape enters legs at any speed | thickness zero or proxies too thin | add thickness, enlarge proxies | | folds slip through each other | particle travel exceeds radius per substep | more substeps, velocity clamp | | cloth puffs and jitters at rest | self-collision radius exceeds half the rest spacing | smaller radius, skip rest neighbours | | a crossed fold never untangles | discrete test pushes to the wrong side | remember side from last valid state | ## Collision against the character Collide cloth against **proxies**, simple shapes such as spheres and capsules attached to the skeleton, rather than the skinned render mesh. Proxies are smooth, cheap to test and do not change topology with animation. Each particle near a proxy gets an inequality constraint, for example `C = dot(p - q, n) - h >= 0`, with `q` the closest surface point, `n` its outward normal and `h` the **collision thickness**. The thickness keeps cloth visibly off the body and gives a margin for the next step's motion. The common sprint bug is temporal. The animation updates once per frame, but the cloth runs several substeps. If every substep sees the proxies at their end-of-frame pose, a leg that swings forward a long way appears inside the cape at once, and projection shoves particles out on whichever side is nearest, often the far side. Interpolating each proxy between its previous and current pose across substeps lets the leg sweep through space as the cloth sees it. Friction against the body is applied as part of the projection or as a velocity edit: the tangential part of the particle's motion is reduced so the cape does not slide off the shoulders. ## The per-substep travel rule A thin collision can only be trusted while particles move less than the thickness per substep. That gives a direct budget: 1. Estimate the fastest particle speed you need to support, for a whipping cape at sprint speed. 2. Choose substeps so that speed times substep length stays below the thickness or self-collision radius. 3. Clamp particle velocity to that bound for rare extremes, accepting a small visual loss. Time-of-impact tests, which find exactly when a moving point crosses a surface, are an alternative for cloth that must never cross, at a higher cost. ## Self-collision Particle-based self-collision gives each particle a radius `r` and keeps every non-neighbouring pair at least `2r` apart. Candidate pairs come from a spatial hash rebuilt each step. Two rules decide whether it behaves: - **Radius against spacing.** If `2r` exceeds the rest distance between neighbouring particles, neighbours always overlap and self-collision fights the distance constraints, so the cloth puffs up and jitters. Keep `2r` at or below the rest spacing, or skip pairs closer than `2r` in the rest pose. - **Gaps between particles.** If particles are spaced much wider than `2r`, another particle can slip between them. Coarse cloth therefore adds vertex-triangle and edge-edge tests against the mesh between particles. ## When it is already tangled A discrete test knows only the current positions. If a particle crossed a triangle within one substep, the nearest-side push sends it further through and locks the tangle in. Robust solvers record, for each close pair, which side it was on in the last state known to be valid, and push it back to that side. Keeping travel below thickness makes this rare; recording sides makes it recoverable.
- Why collide a cape against capsules on the skeleton instead of the skinned render mesh?Capsules are smooth, cheap to test and keep the same shape as the animation plays, so contact normals do not flicker. A skinned mesh has many thin triangles, creases at joints and changing topology near the cloth, which cause snagging and costly tests for detail the cloth cannot use.
- What goes wrong if a cloth particle's self-collision radius exceeds half its rest spacing?Each particle overlaps its own neighbours at rest, so self-collision keeps pushing them apart while distance constraints pull them back. The cloth puffs up and jitters even when still. Shrink the radius, or exclude pairs closer than twice the radius in the rest pose.
- Colliding the cape against the full skinned render mesh is the most robust fix.
- Self-collision must test pairs of particles that share a distance constraint.
- More solver iterations will stop cloth slipping through a fast-moving limb.
- Once cloth has crossed itself, the next collision pass pushes it back to the right side.
- Cloth collision needs no thickness because the rendered cloth is thin.