Position Based Dynamics (PBD): Cloth, Soft Bodies & Constraints
The fluttering fabric in Assassin's Creed, the deformable bodies in Baldur's Gate 3, and the hair simulation in Horizon Forbidden West all run on one idea: instead of computing forces and integrating Newton's laws, directly project particle positions to satisfy geometric constraints. Position Based Dynamics trades physical accuracy for guaranteed stability at any timestep — exactly what real-time games need.
1. Why Not Just Use Forces?
Traditional force-based simulation (mass-spring systems, FEM) computes forces at the current state, then integrates Newton's second law to update positions and velocities. The problem: stiff springs require tiny timesteps to stay stable, and cloth has very stiff springs (otherwise it stretches unrealistically).
A cloth panel with 10 000 particles connected by springs with stiffness k = 10⁶ N/m requires a timestep Δt < √(m/k) ≈ 10⁻⁴ s to remain stable with explicit integration — 600 substeps per 60 fps frame. Implicit integration would require solving a large sparse linear system each substep.
PBD was introduced by Müller et al. in their 2007 SIGGRAPH paper "Position Based Dynamics" and has since become the dominant method for real-time cloth, hair, and soft-body simulation in games and film visual effects toolchains.
2. The PBD Algorithm Loop
The complete PBD simulation loop per frame is:
The crucial property: the inner loop only modifies the predicted positions p, not the actual positions x. Velocity is recovered at the end as a finite difference. This means unstable oscillations cannot build up — any over-correction in p is absorbed as a velocity change at the end of the frame, not fed back into the next constraint projection.
The number of solverIterations controls the
quality-performance tradeoff: 1 iteration is fast but constraints are
not fully satisfied; 10-20 iterations give near-rigid behaviour for
structural constraints.
3. Constraint Types
A constraint is a function C(p₁, …, pₙ) = 0 (equality) or ≥ 0 (inequality) that the predicted positions must satisfy. Common constraint types for cloth and soft bodies:
Distance Constraint
Enforces a fixed rest length between two particles — the cloth "edge" constraint:
Bending Constraint
Resists bending along an edge shared by two triangles. The dihedral angle between the two triangles should match the rest angle:
Volume Conservation Constraint
For soft bodies (deformable meshes), the total volume of a tetrahedron should be preserved:
Collision Constraints
Generated dynamically when a particle penetrates a surface. The inequality constraint pushes the particle back to the surface:
Shape-Matching Constraint
For rigid or near-rigid bodies: compute the optimal rigid transformation (rotation + translation) that maps rest positions to current positions, then pull all particles toward their transformed rest positions. This preserves the overall shape while allowing some elastic deformation.
4. Constraint Projection: The Core Maths
Given a violated constraint C(p₁,…,pₙ) ≠ 0, how do we minimally move the particles to satisfy it? PBD solves a constrained minimisation: find corrections Δpᵢ that minimise ½Σ(1/wᵢ)|Δpᵢ|² subject to C = 0, where wᵢ = 1/mᵢ is the inverse mass.
Distance Constraint Projection (Closed Form)
This closed-form solution is why distance constraint projection is so cheap — just a few float operations per constraint, no matrix factorisation, no iterative solver. The same simplicity applies to almost all PBD constraint types: the gradient ∇C is analytic, and the projection formula has a closed-form solution.
5. Cloth Simulation with PBD
A cloth mesh is a regular or irregular grid of particles connected by three sets of constraints:
Wind and self-collision are handled as additional forces and constraints respectively. Self-collision is the most expensive part: a spatial hash or BVH finds nearby particle pairs, and a distance inequality constraint prevents interpenetration.
Cloth Hanging from Two Pins: Minimal Implementation
Note the Verlet-style integration: velocity is implicit in the
difference pos - prev. This is the "XPBD" or "PBD with
Verlet" variant commonly used in practice — it avoids storing explicit
velocities and gives automatic Rayleigh damping proportional to
velocity.
6. Stiffness, Iterations, and Convergence
In classic PBD, stiffness is controlled only by the number of solver iterations and a per-constraint stiffness parameter k ∈ [0, 1] that partially scales the correction:
This iteration-count dependency is the central practical problem of classic PBD. Doubling iterations makes cloth stiffer; halving iterations (due to a performance budget change) makes cloth floppier. Artists re-tune the simulation every time the solver budget changes — a painful workflow.
Convergence is also slow for stiff constraints in large meshes — the Gauss-Seidel-like projection propagates constraint corrections at the speed of O(1) constraint per iteration, so a wave of deformation needs O(N) iterations to propagate across N particles. Techniques to mitigate this:
- Hierarchical / multigrid PBD: Project constraints at multiple resolution levels simultaneously.
- Chebyshev acceleration: Over-relax corrections with an iteration-dependent coefficient to accelerate convergence.
- Constraint grouping: Independent constraint sets (colourable as non-adjacent graph edges) can be projected in parallel — practical for GPU PBD.
7. XPBD: Extended PBD with Compliance
XPBD (Macklin et al. 2016) fixes the iteration-count dependency by introducing a compliance parameter α that is the reciprocal of physical stiffness and modifies the projection formula with a Lagrange multiplier:
XPBD is the successor to PBD used in all modern physics engines. Unreal Engine's Chaos Physics, NVIDIA PhysX 5, and Unity's ECS cloth all implement XPBD. The compliance parameter α maps directly to physical material properties: α ≈ 10⁻⁸ m/N for near-rigid bone, α ≈ 10⁻⁴ m/N for stiff fabric, α ≈ 10⁻¹ m/N for soft elastic tissue.
Positional vs. Velocity-Level Constraints
XPBD also introduces velocity-level constraint correction at the end of the solver loop (damping), so energy can be correctly dissipated without relying on artificial position-level damping that breaks the XPBD energy model. This enables physically accurate material damping as a separate α_damp parameter.
8. Applications and Industry Usage
PBD and XPBD are the dominant real-time simulation methods across games, film, and medical simulation:
Games
- Cloth: Capes, banners, hair, ropes in virtually every AAA game since 2010. Often 1000–5000 particles per cloth piece, 5–15 solver iterations, substeps: 1–3 per frame.
- Rigid body stacking: XPBD with high stiffness replaces impulse-based solvers for pile stability with similar quality but unified solver code.
- Destruction: Fracture pieces modelled as PBD distance constraints between fragments — breaking constraint when force exceeds a threshold.
Film & VFX
- Houdini Vellum: Production cloth, hair, and grain solver — entirely XPBD-based. Used on dozens of Oscar-winning films. Can run 200 000+ particle simulations with substep counts of 20–100.
- Maya nCloth: Earlier PBD-derived cloth solver in Maya, widely used in TV production.
Medical & Scientific
- Surgical simulators: PBD soft tissue deformation for laparoscopic training — real-time, stable even with large deformations from surgical tools.
- Fluid-like granular materials: PBD density constraints simulate sand, mud, and non-Newtonian fluids. Macklin's "Position Based Fluids" (2013) adds a fluid density constraint alongside SPH kernel functions.
PBD's blend of simplicity, stability, and physical plausibility — even if not strict accuracy — has made it the foundation of real-time physics simulation for over 15 years. XPBD's compliance model now bridges the gap toward physically accurate behaviour, making the method competitive with FEM for many applications where millisecond-scale simulation budgets apply.