---
id: "position-based-dynamics"
title: "Position Based Dynamics"
aliases: [PBD]
domain: "simulation"
stage: "simulation"
realtime: "realtime"
platforms: [webgl2, webgpu, desktop-gpu, cpu, unity, unreal]
year_introduced: 2007
inputs: [particles]
outputs: [particles, mesh]
style: "both"
dynamic: "dynamic"
cost: "medium"
authority: "Müller et al., 2007"
url: "https://texelatlas.vercel.app/t/position-based-dynamics/"
sources_verified_at: "2026-11-29"
---
# Position Based Dynamics (Müller et al., 2007)

> 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.

## 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

## 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 use it

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](https://texelatlas.vercel.app/t/xpbd.md) when stiffness must be independent of iteration count and timestep, [Vertex Block Descent](https://texelatlas.vercel.app/t/vertex-block-descent.md) when you need stiffer, higher-fidelity cloth that converges faster, and [Implicit cloth integration (Baraff-Witkin)](https://texelatlas.vercel.app/t/implicit-cloth-integration.md) when you need physically calibrated cloth with large steps on CPU. Prefer [Verlet integration with relaxation constraints](https://texelatlas.vercel.app/t/verlet-integration-constraints.md) for the simplest ropes and ragdolls.

## Cost

medium — Linear in constraints x iterations; massively parallel with graph colouring or Jacobi. Qualitative only.
Measured GPU Weight: 57.22× baseline (heavy) — 1.7966 ms median / 1.8616 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 50.13× baseline (heavy) — 0.7921 ms median (2.27× faster on L4).
Ampere A100 scaling: 40.27× baseline (heavy) — 1.1597 ms median (1.55× faster on A100).

## Failure modes

- 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

## Engine support

- blender: builtin — `Geometry Nodes > Simulation > XPBD Solver` (evidence: https://docs.blender.org/manual/en/5.2/modeling/geometry_nodes/simulation/xpbd_solver.html, checked 2026-12-01) — The solver implements the XPBD variant of PBD.
- godot: builtin — `SoftBody3D under GodotPhysics3D solves deformable meshes with classic PBD edge constraints` (evidence: https://github.com/godotengine/godot/blob/4.7.2-stable/modules/jolt_physics/objects/jolt_soft_body_3d.cpp, checked 2026-12-01)
- unreal: builtin — `Chaos Cloth (ChaosClothAsset and ClothingSimulationInteractor iterative substepped position-based cloth constraints)` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/python-api/class/ChaosClothAsset, checked 2026-12-01)

## Dataflow

- Inputs: particles
- Outputs: particles, mesh
- Platforms: webgl2, webgpu, desktop-gpu, cpu, unity, unreal

## Presets

### Position Based Dynamics — real-time iterative Gauss-Seidel distance constraint solver & collider projection (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_ITERATIONS": 8,
  "P_STIFFNESS": 0.92,
  "P_GRAVITY": 1,
  "P_COLLIDER_SPEED": 1
}
```

```glsl
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).

## Lineage

- extended by [Tethered Lattice Adhesive Peeling and Delamination Front](https://texelatlas.vercel.app/t/tethered-lattice-adhesive-delamination.md)
- extended by [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md)
- superseded by [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md)

## Combines with

- [Linear blend skinning](https://texelatlas.vercel.app/t/linear-blend-skinning.md): PBD cloth or soft bodies simulate secondary motion on top of a skinned character's skeleton-driven positions

## Sources

1. [primary] Matthias Müller, Bruno Heidelberger, Marcus Hennix, John Ratcliff (2007) Position based dynamics. Journal of Visual Communication and Image Representation. https://doi.org/10.1016/j.jvcir.2007.01.005 (verified via crossref on 2026-11-29)
2. [implementation] InteractiveComputerGraphics (2015) InteractiveComputerGraphics/PositionBasedDynamics. https://github.com/InteractiveComputerGraphics/PositionBasedDynamics License: MIT. (verified via github on 2026-11-29)
3. [tutorial] Matthias Müller Ten Minute Physics. matthias-research.github.io. https://matthias-research.github.io/pages/tenMinutePhysics (verified via http on 2026-11-29)

## Cite this entry

Texel. "Position Based Dynamics." https://texelatlas.vercel.app/t/position-based-dynamics/ (accessed 2026-12-01).
