Position Based Dynamics
Simulates cloth, soft bodies and ropes by predicting particle positions and then projecting them directly onto constraint manifolds, skipping forces and stiffness-induced blow-ups.
Also known as PBD
In the family Simulation & animation, particle/constraint solvers
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Built in | SoftBody3D under GodotPhysics3D solves deformable meshes with classic PBD edge constraints docs |
| Unity | None found | |
| Unreal 5.7 | Built in | Chaos Cloth (ChaosClothAsset and ClothingSimulationInteractor iterative substepped position-based cloth constraints) docs |
| Blender 5.2 | Built in | Geometry Nodes > Simulation > XPBD Solver docs The solver implements the XPBD variant of PBD. |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Each step integrates velocities with external forces to get predicted positions. Constraints (distance, bending, volume, collision) are then solved by Gauss-Seidel or Jacobi iteration: each constraint computes a position correction along its gradient, weighted by inverse mass, and applies it immediately. After the iterations the velocity is recovered as (x_new - x_old)/dt, so the position edits become implicit velocity changes. Because corrections are geometric rather than force-based, the scheme is unconditionally stable; stiffness is controlled by the iteration count and a per-constraint stiffness scalar, not by a physical modulus. Collisions are handled as inequality constraints produced by a broad phase (spatial hash is typical).
When to choose it
Reach for it when
- need stable real-time cloth or soft body in games
- physics simulation explodes with stiff constraints
- interactive deformable objects with simple code
- controllable ropes and cloth without force tuning
Choose it when you need unconditionally stable, controllable cloth/rope/soft-body in a game or interactive tool and exact material response does not matter. Prefer Extended Position-Based Dynamics when stiffness must be independent of iteration count and timestep, Vertex Block Descent when you need stiffer, higher-fidelity cloth that converges faster, and Implicit cloth integration (Baraff-Witkin) when you need physically calibrated cloth with large steps on CPU. Prefer Verlet integration with relaxation constraints for the simplest ropes and ragdolls.
Field marks
- Stiffness depends on iteration count and time step, so changing frame rate changes how stretchy cloth looks
- Slow convergence on long chains and high mass ratios: hanging chains stretch like rubber
- Energy dissipation from the velocity update makes motion look damped
- Jacobi variants converge slower than Gauss-Seidel and need over-relaxation, which can jitter
- Cloth self-collision with thin thickness tunnels at high speeds
Presets
Position Based Dynamics — real-time iterative Gauss-Seidel distance constraint solver & collider projection
{
"P_ITERATIONS": 8,
"P_STIFFNESS": 0.92,
"P_GRAVITY": 1,
"P_COLLIDER_SPEED": 1
}Show GLSL (129 lines)
const float P_ITERATIONS = 8.0; // P Solver Iters [1.0, 14.0, 1.0]
const float P_STIFFNESS = 0.92; // P Stiffness k [0.2, 1.0, 0.02]
const float P_GRAVITY = 1.0; // P Gravity [0.2, 2.0, 0.05]
const float P_COLLIDER_SPEED = 1.0; // P Collider Speed [0.0, 2.5, 0.05]
float sdSegment(vec2 p, vec2 a, vec2 b) {
vec2 pa = p - a, ba = b - a;
float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
return length(pa - ba * h);
}
vec3 strainColor(float s) {
s = clamp(s, 0.0, 1.0);
vec3 c0 = vec3(0.14, 0.82, 0.92);
vec3 c1 = vec3(0.98, 0.80, 0.22);
vec3 c2 = vec3(1.00, 0.24, 0.34);
if (s < 0.5) return mix(c0, c1, s * 2.0);
return mix(c1, c2, (s - 0.5) * 2.0);
}
vec3 aces(vec3 x) {
x = max(x, 0.0);
return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
float px = 1.0 / max(iResolution.y, 1.0);
float tAnim = iTime * max(P_COLLIDER_SPEED, 0.0);
int nIter = int(clamp(floor(P_ITERATIONS + 0.5), 1.0, 14.0));
float stiff = clamp(P_STIFFNESS, 0.15, 1.0);
float grav = clamp(P_GRAVITY, 0.15, 2.2);
// Moving rigid spherical collider pressing into a 11-node pinned PBD chain
vec2 collPos = vec2(0.28 * sin(tAnim * 0.72), -0.05 + 0.16 * cos(tAnim * 1.05));
float collRad = 0.175;
// Initialize 11 PBD particles with unconstrained predicted positions x* = x + dt*v + dt^2*g
vec2 pos[11];
float restLen = 0.132;
vec2 pinL = vec2(-0.62, 0.28);
vec2 pinR = vec2(0.62, 0.28);
for (int i = 0; i < 11; i++) {
float u = float(i) / 10.0;
float sag = sin(u * 3.14159265) * (0.42 * grav);
float sway = sin(u * 6.28318 + tAnim * 1.4) * 0.03 * sin(u * 3.14159);
pos[i] = mix(pinL, pinR, u) + vec2(sway, -sag);
}
// Genuine Position Based Dynamics iterative constraint projection loop (Gauss-Seidel)
for (int it = 0; it < 14; it++) {
if (it >= nIter) break;
// Distance constraints C(p_i, p_{i+1}) = |p_{i+1} - p_i| - d = 0
for (int i = 0; i < 10; i++) {
vec2 delta = pos[i + 1] - pos[i];
float len = max(length(delta), 1e-5);
float diff = (len - restLen) / len;
vec2 corr = delta * diff * 0.5 * stiff;
if (i > 0) pos[i] += corr;
if (i + 1 < 10) pos[i + 1] -= corr;
}
// Inequality collision constraint C_col(p_i) = |p_i - c| - R >= 0
for (int i = 1; i < 10; i++) {
vec2 dc = pos[i] - collPos;
float d = length(dc);
if (d < collRad + 0.022) {
pos[i] = collPos + (dc / max(d, 1e-5)) * (collRad + 0.022);
}
// Subtle bending smoothing between neighbors
if (i > 1 && i < 9) {
vec2 mid = 0.5 * (pos[i - 1] + pos[i + 1]);
pos[i] = mix(pos[i], mid, 0.04 * stiff);
}
}
pos[0] = pinL;
pos[10] = pinR;
}
// Technical studio blueprint background
vec3 col = mix(vec3(0.03, 0.04, 0.065), vec3(0.065, 0.085, 0.125), smoothstep(-0.5, 0.5, uv.y));
vec2 g = abs(fract(uv * 10.0 - 0.5) - 0.5);
col += vec3(0.022, 0.032, 0.048) * smoothstep(0.03, 0.005, min(g.x, g.y));
// Unconstrained predicted parabolic curve (ghost reference showing gravity before PBD projection)
float dGhost = 1e5;
for (int i = 0; i < 10; i++) {
float u0 = float(i) / 10.0;
float u1 = float(i + 1) / 10.0;
vec2 g0 = mix(pinL, pinR, u0) + vec2(0.0, -sin(u0 * 3.14159265) * 0.42 * grav);
vec2 g1 = mix(pinL, pinR, u1) + vec2(0.0, -sin(u1 * 3.14159265) * 0.42 * grav);
dGhost = min(dGhost, sdSegment(uv, g0, g1));
}
float dash = step(0.45, fract((uv.x + 1.0) * 18.0));
col = mix(col, vec3(0.28, 0.36, 0.50), smoothstep(px * 2.5, px * 0.6, dGhost) * 0.55 * dash);
// Shaded rigid sphere collider with contact halo
float dColl = length(uv - collPos) - collRad;
if (dColl < 0.0) {
vec2 rel = (uv - collPos) / collRad;
float nz = sqrt(max(1.0 - dot(rel, rel), 0.0));
vec3 cn = normalize(vec3(rel, nz));
float cDiff = max(dot(cn, normalize(vec3(0.55, 0.72, 0.65))), 0.0);
float cSpec = pow(max(dot(cn, normalize(vec3(0.45, 0.65, 0.85))), 0.0), 36.0);
col = vec3(0.14, 0.19, 0.28) * (0.32 + 0.85 * cDiff) + vec3(0.75, 0.86, 1.0) * cSpec * 0.48;
}
col = mix(col, vec3(0.42, 0.72, 1.0), smoothstep(px * 3.2, px * 0.6, abs(dColl)) * 0.75);
// Draw PBD constraint edges colored by residual stretch strain | |p_j - p_i| - d | / d
for (int i = 0; i < 10; i++) {
float segLen = length(pos[i + 1] - pos[i]);
float strain = abs(segLen - restLen) / max(restLen * 0.28, 1e-4);
float dSeg = sdSegment(uv, pos[i], pos[i + 1]);
vec3 eCol = strainColor(strain);
col += eCol * exp(-dSeg * 75.0) * 0.35;
col = mix(col, eCol, smoothstep(0.011, 0.004, dSeg));
}
// Draw PBD mass nodes (pinned anchors in gold, dynamic nodes in ivory/cyan)
for (int i = 0; i < 11; i++) {
float dp = length(uv - pos[i]);
bool isPin = (i == 0 || i == 10);
float rad = isPin ? 0.026 : 0.020;
vec3 nCol = isPin ? vec3(1.0, 0.78, 0.24) : vec3(0.92, 0.96, 1.0);
col = mix(col, vec3(0.05, 0.07, 0.10), smoothstep(rad + 0.007, rad + 0.001, dp));
col = mix(col, nCol, smoothstep(rad, rad - 0.005, dp));
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| position-based-dynamics-live | Tesla T4 1920x1080 | 57.2× baseline (heavy) · 1.80 ms / 1.86 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| position-based-dynamics-live | NVIDIA L4 1920x1080 | 50.1× baseline (heavy) · 0.792 ms / 0.796 ms · 2.3× faster on L4 | opengl-timer-query · Cross-architecture validation |
| position-based-dynamics-live | NVIDIA A100-SXM4-40GB 1920x1080 | 40.3× baseline (heavy) · 1.16 ms / 1.16 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
From the citation graph (Crossref reference lists): its primary source cites Shape matching (meshless deformation); cited by Implicit cloth integration (Baraff-Witkin), Position Based Fluids, Soft Step solver / substepping, Unified particle physics, Vertex Block Descent.
Crosses
- Linear blend skinning: PBD cloth or soft bodies simulate secondary motion on top of a skinned character's skeleton-driven positions
Sources
- primaryMatthias Müller, Bruno Heidelberger, Marcus Hennix, John Ratcliff (2007). Position based dynamics. Journal of Visual Communication and Image Representation.Verified via crossref · 2026-11-29doi:10.1016/j.jvcir.2007.01.005
- implementationInteractiveComputerGraphics (2015). InteractiveComputerGraphics/PositionBasedDynamics. PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.GitHub API · license MIT · 2026-11-29
- tutorialMatthias Müller. Ten Minute Physics. matthias-research.github.io.Verified via live page · 2026-11-29