Why does a PBD cloth's stiffness change with the solver iteration count and step length, and how does XPBD compliance fix it?
answer
- softness as unconverged error
- per-iteration factor compounds
- compliance is inverse stiffness
- alpha over dt squared, lambda per constraint
- substeps beat iterations
basics
~20 sPBD has no physical stiffness: softness is whatever the solve leaves unconverged, so more iterations or shorter steps make cloth stiffer. XPBD adds compliance and a per-constraint Lagrange multiplier, so the requested stiffness becomes a material property.
solid answer
~50 sIn PBD a constraint is projected fully, or scaled by a factor `k`, each time it is visited, and nothing else defines its softness. More iterations, or more steps per second, apply more corrections, so the same `k` gives stiffer cloth; even `k = 1` looks stretchy when the solve stops early, because corrections spread through a long chain or sheet only gradually. XPBD gives each constraint a **compliance** `alpha` (inverse stiffness), uses `alphaTilde = alpha / dt^2`, and accumulates a **Lagrange multiplier** `lambda`, reset each step, with `dLambda = (-C - alphaTilde*lambda) / (sum of w*|grad C|^2 + alphaTilde)`. The solve converges toward the compliant answer, so a stiffness value means the same at any iteration count or step length; too few iterations still leave some residual stretch. For stiffness per unit of cost, many substeps with one iteration each usually beat one step with many iterations.
code
pseudocode · 14 lines// at the start of each step or substep: c.lambda = 0 for every constraint
function projectDistanceXPBD(A, B, c, dt):
wSum = A.invMass + B.invMass
if wSum == 0: return
d = A.p - B.p
len = length(d)
if len < 1e-9: return
n = d / len
C = len - c.restLength
alphaTilde = c.compliance / (dt * dt) // compliance = 1 / stiffness
dLambda = (-C - alphaTilde * c.lambda) / (wSum + alphaTilde)
c.lambda = c.lambda + dLambda
A.p = A.p + A.invMass * dLambda * n
B.p = B.p - B.invMass * dLambda * ngo deeper
Remember that PBD cloth gets stiffer with more iterations, and that XPBD adds a compliance value meaning inverse stiffness.
Explain why a per-visit stiffness factor compounds with iterations and steps, and write the XPBD multiplier update for a distance constraint.
Diagnose a stretchy cape or flag: separate material from convergence, move stiffness into compliance, prefer substeps to iterations, and add tethers to pinned cloth and ropes.
Set a team policy: artist-facing stiffness in physical compliance so assets survive changes to iteration and substep budgets across platforms.
## Where PBD's stiffness comes from **Position-based dynamics (PBD)** moves particles onto their constraints instead of applying forces. A distance constraint projected with factor `k = 1` is, if the solve converged, perfectly rigid. To make cloth softer, classic PBD scales every correction by a stiffness factor `0 <= k <= 1`. That factor has no units and no physical meaning; it says only "move this fraction of the way per visit". Two consequences follow. - **Iteration count changes stiffness.** With `n` iterations the remaining error of an isolated constraint shrinks as `(1 - k)^n`, so doubling the iterations makes the cloth stiffer. The classic correction uses `k' = 1 - (1 - k)^(1/n)` per iteration so that `n` passes remove a fraction `k` overall, which makes the result roughly independent of `n` for an isolated constraint. - **Step length changes stiffness.** The factor applies per step, so running twice as many shorter steps per second applies twice as many corrections and stiffens the cloth again. The `k'` trick does nothing about that. Even at `k = 1` a long rope or a large flag rarely converges. With Gauss-Seidel projection a correction spreads through a chain or sheet only gradually, so a hanging cape with a few iterations sags and stretches like rubber, and raising its resolution makes it worse. ## XPBD: compliance and the Lagrange multiplier **Extended position-based dynamics (XPBD)** gives every constraint a **compliance** `alpha`, the inverse of its stiffness in physical units, and an accumulated **Lagrange multiplier** `lambda`. Per step: 1. Reset `lambda = 0` for every constraint and predict positions as in PBD. 2. Compute `alphaTilde = alpha / dt^2`, where `dt` is the step or substep length. 3. For each constraint in each iteration, compute `dLambda = (-C - alphaTilde * lambda) / (sum_j w_j * |grad_j C|^2 + alphaTilde)`. 4. Add `dLambda` to `lambda` and move each particle by `w_j * grad_j C * dLambda`. For a distance constraint the denominator is `w1 + w2 + alphaTilde`. With `alpha = 0` the update is exactly PBD at `k = 1`. With `alpha > 0` the term `alphaTilde * lambda` remembers how much force the constraint has already applied, so repeated visits converge to the compliant balance rather than marching all the way to `C = 0`. Dividing by `dt^2` is what ties a position correction to a force: `lambda / dt^2` is the constraint force, so the same `alpha` means the same material at any step length. What XPBD fixes is the **target**. It does not make one iteration converge: with too few iterations the solve still stops short, and the shortfall shows as extra stretch. But adding iterations now approaches a fixed physical answer instead of making the material itself stiffer. | | PBD with factor `k` | XPBD with compliance `alpha` | |---|---|---| | Meaning of the parameter | fraction of correction per visit | inverse stiffness, physical units | | More iterations | stiffer material | closer to the same material | | Shorter steps | stiffer material | same material | | Constraint force | not available | `lambda / dt^2` | ## Substeps against iterations With a fixed budget of projections per frame, there are two ways to spend it: one step with many iterations, or many substeps with one iteration each. Substepping usually wins. After prediction, the constraint error each step starts with shrinks with the square of the step length, because the predicted drift off a constraint grows with `dt^2`. Small substeps begin almost converged, so one projection removes most of what remains, and the cloth comes out stiffer and less artificially damped for the same cost. The price is everything else done per substep: - prediction and velocity update run each substep; - collision constraints must stay valid, so many solvers find candidate collisions once per frame and only re-test them per substep. How the integrator itself behaves with smaller steps is a separate subject; here substeps matter only as a better way to spend projections. ## Stretch that iterations will not fix: long-range attachments A hanging cape or a rope bridge's ropes are pinned at one end, and stretch accumulates down the chain. A cheap fix is a **long-range attachment**, also called a tether: for each free particle, an inequality constraint to its attachment point that only acts when the particle is farther away than its rest distance. Only the free particle moves, because the attachment is pinned. One projection per tether removes the visible sag, however few iterations the distance constraints get. ## Diagnosing a rubber flag 1. Check whether stiffness changes when iteration count or step rate changes; if so, the material is a PBD factor, not a compliance. 2. Move the stiffness into compliance and keep it fixed while you tune iterations. 3. Spend the budget on substeps before iterations. 4. Add tethers for pinned cloth and ropes before raising either.
- How can you read the tension in a rope bridge's rope from an XPBD solve?Each distance constraint's accumulated multiplier gives its force: the tension is about `|lambda| / dt^2`, with `dt` the substep length. Compare it against a breaking threshold to snap a rope when the player overloads the bridge. Classic PBD cannot do this, because its corrections carry no physical scale.
- Why do many substeps with one iteration usually beat one step with many iterations?Each substep starts with a constraint error that shrinks with the square of its length, so one projection removes most of it, and the cloth ends stiffer and less damped for the same number of projections. The extra cost is prediction, velocity updates and collision upkeep run every substep.
- What does a compliance of zero mean in XPBD?An infinitely stiff constraint. The multiplier update reduces to the PBD projection at full stiffness, so the target is `C = 0`. It still needs enough iterations or substeps to get there; zero compliance sets the goal, not the convergence.
PBD stiffness is like how tight a slack line gets when someone tugs it a few times per second: the tension you see depends on how many tugs there are time for, not on the line. XPBD prints the line's elasticity on the label, and extra tugs only bring you closer to what the label says.
- Setting PBD's stiffness factor to one guarantees cloth that never stretches.
- XPBD makes a cloth solve converge fully in a single iteration.
- XPBD compliance is just PBD's stiffness factor under another name.
- Halving the step length leaves PBD cloth stiffness unchanged.
- Adding solver iterations always beats adding substeps for the same cost.