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

> Adds a compliance term to position-based constraint solving so stiffness is a real material parameter independent of time step and iteration count, while keeping PBD's stability.

## Reach for it when

- cloth stiffness changes with frame rate or iterations
- need position-based solver with real material stiffness
- want breakable constraints and motors with force readout
- position-based dynamics feels time-step dependent
- stable soft-body or rope simulation with consistent behaviour

## How it works

XPBD derives from implicit Euler with a constraint energy `1/2 C^T alpha^{-1} C`, where `alpha` is inverse stiffness (compliance). It keeps a Lagrange multiplier per constraint across iterations of the same step. Each iteration computes a multiplier increment `dlambda = (-C - alpha~ * lambda) / (grad C M^-1 grad C^T + alpha~)` with `alpha~ = alpha/dt^2`, then applies the position change along the gradient. When compliance is zero it reduces to plain PBD; when it is positive the constraint behaves like a spring whose force converges to the true implicit solution as iterations increase. Since the multiplier is also the constraint force (times dt^2), it can be used to read out forces for e.g. breakable joints. Combined with substepping it is the common modern realtime solver.

## When to use it

Choose it when you want PBD's robustness but need consistent stiffness across frame rates, or need constraint forces (breaking, motors). Prefer [Position Based Dynamics](https://texelatlas.vercel.app/t/position-based-dynamics.md) only for the very simplest cases where one scalar is enough, [Soft Step solver / substepping](https://texelatlas.vercel.app/t/soft-step-solver.md) / substepping for rigid-body-dominant scenes, and [Vertex Block Descent](https://texelatlas.vercel.app/t/vertex-block-descent.md) when you need guaranteed convergence on stiff, high-ratio cloth.

## Cost

medium — Same order as PBD plus one multiplier per constraint; usually run with many substeps rather than many iterations.
Measured GPU Weight: 145.23× baseline (extreme) — 4.5021 ms median / 4.7383 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 129.82× baseline (extreme) — 2.0641 ms median (2.18× faster on L4).
Ampere A100 scaling: 101.55× baseline (extreme) — 2.9245 ms median (1.54× faster on A100).

## Failure modes

- Still not exact: very stiff constraints with few iterations remain soft
- Large mass ratios converge slowly even with compliance
- Damping must be added as a separate constraint-space term or motion looks overly dissipative
- Multiplier history makes constraint add/remove mid-step (contacts) slightly fiddly

## 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) — For hair, cloth and particles.
- godot: builtin — `SoftBody3D with JoltPhysics3D solves soft bodies via Extended Position-Based Dynamics (Jolt SoftBodyMotionProperties)` (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 — `Cloth Panel Node Editor: add XPBD constraints to a Chaos Cloth asset` (evidence: https://dev.epicgames.com/documentation/en-us/unreal-engine/panel-cloth-editor-overview, checked 2026-12-01) — Chaos Cloth; optional XPBD constraint types in the panel cloth editor.

## Dataflow

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

## Presets

### XPBD — stiff PBD alpha=0 (left) vs compliant XPBD elastic chain & strain heatmap (right) (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_COMPLIANCE": 0.42,
  "P_GRAVITY": 1,
  "P_SPEED": 1,
  "P_SPLIT": 0.48
}
```

```glsl
const float P_COMPLIANCE = 0.42; // P Compliance Alpha [0.0, 1.5, 0.02]
const float P_GRAVITY = 1.0; // P Gravity Load [0.2, 2.2, 0.05]
const float P_SPEED = 1.0; // P Osc Speed [0.0, 2.5, 0.05]
const float P_SPLIT = 0.48; // P PBD / XPBD Split [0.0, 1.0, 0.02]

float sdSeg(vec2 p, vec2 a, vec2 b, out float h) {
  vec2 pa = p - a;
  vec2 ba = b - a;
  h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);
  return length(pa - ba * h);
}

vec3 strainRamp(float s) {
  float t = clamp(s, 0.0, 1.0);
  vec3 c0 = vec3(0.14, 0.62, 0.92);
  vec3 c1 = vec3(0.18, 0.88, 0.62);
  vec3 c2 = vec3(0.98, 0.72, 0.16);
  vec3 c3 = vec3(0.96, 0.24, 0.22);
  if (t < 0.33) return mix(c0, c1, t * 3.0);
  if (t < 0.66) return mix(c1, c2, (t - 0.33) * 3.0);
  return mix(c2, c3, (t - 0.66) * 3.0);
}

// Compute node position of a 7-node elastic XPBD chain with compliance alpha
vec2 xpbdNode(int idx, float alpha, float grav, float t, float xOff) {
  float fi = float(idx);
  float restL = 0.105;
  vec2 anchor = vec2(xOff, 0.36);
  if (idx == 0) return anchor;

  // Iterative XPBD equilibrium: dLambda = (-C - alphaTilde * lam) / (wSum + alphaTilde)
  // Static stretch scales with alphaTilde * loadBelow; dynamic swing scales with compliance
  float dt = 0.016;
  float alphaTilde = alpha * 0.0018 / (dt * dt + 1e-5);
  float wSum = 2.0;
  float kComp = alphaTilde / (wSum + alphaTilde + 1e-5);

  float swayPhase = t * (2.15 - 0.55 * kComp);
  float wind = 0.11 * sin(swayPhase) + 0.045 * sin(swayPhase * 2.3 + 0.8);

  vec2 pos = anchor;
  for (int k = 1; k <= 7; k++) {
    if (k > idx) break;
    float fk = float(k);
    float loadBelow = (8.0 - fk) * grav;
    // XPBD analytical steady-state compliance elongation per link
    float stretch = restL * (0.018 + 0.24 * kComp * loadBelow * 0.28);
    float L = restL + stretch;
    float ang = wind * (0.55 + 0.34 * fk) * (1.0 + 0.65 * kComp) + 0.08 * sin(swayPhase * 1.4 - fk * 0.52) * (0.4 + kComp);
    pos += vec2(sin(ang), -cos(ang)) * L;
  }
  return pos;
}

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 screenX = fragCoord.x / max(iResolution.x, 1.0);
  float split = clamp(P_SPLIT, 0.0, 1.0);
  float alphaRight = max(P_COMPLIANCE, 0.0);
  float grav = clamp(P_GRAVITY, 0.2, 2.5);
  float t = iTime * max(P_SPEED, 0.0);

  // Dark engineering blueprint grid
  vec3 col = mix(vec3(0.028, 0.038, 0.058), vec3(0.055, 0.074, 0.112), smoothstep(-0.5, 0.5, uv.y));
  vec2 g1 = abs(fract(uv * 10.0 - 0.5) - 0.5);
  vec2 g2 = abs(fract(uv * 2.0 - 0.5) - 0.5);
  col += vec3(0.016, 0.024, 0.038) * smoothstep(0.035, 0.008, min(g1.x, g1.y));
  col += vec3(0.028, 0.042, 0.068) * smoothstep(0.014, 0.003, min(g2.x, g2.y));

  // Top ceiling beam
  float dBeam = abs(uv.y - 0.385) - 0.025;
  col = mix(col, vec3(0.16, 0.20, 0.27), smoothstep(px * 2.0, 0.0, dBeam));
  float hatch = smoothstep(0.45, 0.55, sin((uv.x + uv.y) * 90.0));
  col = mix(col, vec3(0.24, 0.30, 0.39), smoothstep(px * 2.0, 0.0, dBeam) * hatch * 0.45);

  // Draw two chains on each side (stiff left alpha=0, compliant right alpha=P_COMPLIANCE)
  float restL = 0.105;
  for (int side = 0; side < 2; side++) {
    bool isRight = (side == 1);
    float alpha = isRight ? alphaRight : 0.0;
    float xBase = isRight ? 0.34 : -0.34;
    float sideMask = isRight ? smoothstep(split - 0.004, split + 0.004, screenX) : smoothstep(split + 0.004, split - 0.004, screenX);

    // Draw two coupled strands forming a narrow compliant ladder/ribbon
    for (int strand = 0; strand < 2; strand++) {
      float dx = (strand == 0) ? -0.095 : 0.095;
      vec2 prevP = xpbdNode(0, alpha, grav, t + float(strand) * 0.18, xBase + dx);
      vec2 prevRest = vec2(xBase + dx, 0.36);

      for (int i = 1; i <= 7; i++) {
        vec2 curP = xpbdNode(i, alpha, grav, t + float(strand) * 0.18, xBase + dx);
        vec2 curRest = vec2(xBase + dx, 0.36 - float(i) * restL);

        // Rest-length ghost guide
        float hGhost;
        float dGhost = sdSeg(uv, prevRest, curRest, hGhost);
        float dash = step(0.5, fract(hGhost * 4.0));
        col += vec3(0.16, 0.22, 0.32) * smoothstep(px * 2.2, px * 0.5, dGhost) * dash * 0.45 * sideMask;

        // Elastic constraint spring segment
        float hSeg;
        float dSeg = sdSeg(uv, prevP, curP, hSeg);
        float segLen = length(curP - prevP);
        float strain = clamp((segLen - restL) / (restL * 0.38), 0.0, 1.0);
        vec3 sCol = strainRamp(strain);

        // Coiled spring wave modulation along the segment
        vec2 dir = (curP - prevP) / max(segLen, 1e-5);
        vec2 perp = vec2(-dir.y, dir.x);
        float coils = sin(hSeg * 6.2831853 * 6.0) * (0.011 - 0.004 * strain);
        vec2 springPt = mix(prevP, curP, hSeg) + perp * coils * smoothstep(0.0, 0.12, hSeg) * smoothstep(1.0, 0.88, hSeg);
        float dSpring = length(uv - springPt);

        float linkCore = smoothstep(0.0085, 0.003, dSeg);
        float coilGlow = smoothstep(0.007, 0.002, dSpring);
        col = mix(col, sCol * 1.15, max(linkCore * 0.72, coilGlow * 0.92) * sideMask);

        // Horizontal shear rung between the two strands
        if (strand == 1) {
          vec2 leftP = xpbdNode(i, alpha, grav, t, xBase - 0.095);
          float hRung;
          float dRung = sdSeg(uv, leftP, curP, hRung);
          float rungStrain = clamp(abs(length(curP - leftP) - 0.19) / 0.08, 0.0, 1.0);
          col = mix(col, strainRamp(rungStrain) * 0.85, smoothstep(0.006, 0.002, dRung) * 0.75 * sideMask);
        }

        // Mass node sphere + compliance energy halo
        float rNode = (i == 7) ? 0.028 : 0.019;
        float dNode = length(uv - curP);
        if (dNode < rNode) {
          vec2 local = (uv - curP) / rNode;
          float z = sqrt(max(1.0 - dot(local, local), 0.0));
          vec3 n = normalize(vec3(local, z));
          float diff = max(dot(n, normalize(vec3(0.45, 0.7, 0.6))), 0.0);
          float spec = pow(max(dot(n, normalize(vec3(0.3, 0.5, 1.0))), 0.0), 32.0);
          vec3 nodeCol = mix(vec3(0.75, 0.84, 0.96), sCol, 0.45) * (0.35 + 0.75 * diff) + vec3(0.95) * spec * 0.7;
          col = mix(col, nodeCol, sideMask);
        }
        float halo = smoothstep(rNode + 0.016, rNode, dNode) * smoothstep(rNode - 0.002, rNode + 0.004, dNode);
        col += sCol * halo * (0.35 + 0.65 * strain) * sideMask;

        prevP = curP;
        prevRest = curRest;
      }

      // Anchor pin
      float dPin = length(uv - vec2(xBase + dx, 0.36));
      col = mix(col, vec3(0.95, 0.82, 0.36), smoothstep(0.018, 0.011, dPin) * sideMask);
    }
  }

  // Split divider line
  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
  col = mix(col, vec3(0.94, 0.97, 1.0), sep);

  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extends [Position Based Dynamics](https://texelatlas.vercel.app/t/position-based-dynamics.md)
- supersedes [Position Based Dynamics](https://texelatlas.vercel.app/t/position-based-dynamics.md)
- extended by [Vertex Block Descent](https://texelatlas.vercel.app/t/vertex-block-descent.md)

## Combination ideas

- [Deformable XPBD soft bodies carved straight from NeuS captures](https://texelatlas.vercel.app/ideas/neus-captured-xpbd-soft-bodies/)

## Sources

1. [primary] Miles Macklin, Matthias Müller, Nuttapong Chentanez (2016) XPBD. Proceedings of the 9th International Conference on Motion in Games. https://doi.org/10.1145/2994258.2994272 (verified via crossref on 2026-11-29)
2. [primary] Miles Macklin, Kier Storey, Michelle Lu, Pierre Terdiman, Nuttapong Chentanez, Stefan Jeschke, Matthias Müller (2019) Small steps in physics simulation. Proceedings of the 18th annual ACM SIGGRAPH/Eurographics Symposium on Computer Animation. https://doi.org/10.1145/3309486.3340247 (verified via crossref on 2026-11-29)
3. [implementation] InteractiveComputerGraphics (2015) InteractiveComputerGraphics/PositionBasedDynamics. https://github.com/InteractiveComputerGraphics/PositionBasedDynamics License: MIT. (verified via github on 2026-11-29)

## Cite this entry

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