{
 "id": "xpbd",
 "title": "Extended Position-Based Dynamics",
 "aliases": [
  "Extended PBD"
 ],
 "domain": "simulation",
 "subdomain": "particle/constraint solvers",
 "stage": "simulation",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cpu",
  "unity",
  "unreal"
 ],
 "year_introduced": 2016,
 "inputs": [
  "particles"
 ],
 "outputs": [
  "particles",
  "mesh"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "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.",
 "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": "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` only for the very simplest cases where one scalar is enough, `soft-step-solver` / substepping for rigid-body-dominant scenes, and `vertex-block-descent` when you need guaranteed convergence on stiff, high-ratio cloth.",
 "cost": {
  "class": "medium",
  "notes": "Same order as PBD plus one multiplier per constraint; usually run with many substeps rather than many iterations."
 },
 "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/2994258.2994272",
   "type": "paper",
   "title": "XPBD",
   "authors": [
    "Miles Macklin",
    "Matthias Müller",
    "Nuttapong Chentanez"
   ],
   "year": 2016,
   "venue": "Proceedings of the 9th International Conference on Motion in Games",
   "url": "https://doi.org/10.1145/2994258.2994272",
   "ids": {
    "doi": "10.1145/2994258.2994272"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2994258.2994272",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2994258.2994272",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2994258.2994272",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2994258.2994272",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/2994258.2994272",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 0.9,
   "__bib": "macklin2016xpbd"
  },
  {
   "role": "primary",
   "key": "doi:10.1145/3309486.3340247",
   "type": "paper",
   "title": "Small steps in physics simulation",
   "authors": [
    "Miles Macklin",
    "Kier Storey",
    "Michelle Lu",
    "Pierre Terdiman",
    "Nuttapong Chentanez",
    "Stefan Jeschke",
    "Matthias Müller"
   ],
   "year": 2019,
   "venue": "Proceedings of the 18th annual ACM SIGGRAPH/Eurographics Symposium on Computer Animation",
   "url": "https://doi.org/10.1145/3309486.3340247",
   "ids": {
    "doi": "10.1145/3309486.3340247"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3309486.3340247",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3309486.3340247",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3309486.3340247",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3309486.3340247",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145/3309486.3340247",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "macklin2019small"
  },
  {
   "role": "implementation",
   "key": "gh:interactivecomputergraphics/positionbaseddynamics",
   "type": "code",
   "title": "InteractiveComputerGraphics/PositionBasedDynamics",
   "description": "PositionBasedDynamics is a library for the physically-based simulation of rigid bodies, deformable solids and fluids.",
   "authors": [
    "InteractiveComputerGraphics"
   ],
   "year": 2015,
   "venue": "GitHub",
   "url": "https://github.com/InteractiveComputerGraphics/PositionBasedDynamics",
   "ids": {
    "repo": "InteractiveComputerGraphics/PositionBasedDynamics"
   },
   "license": "MIT",
   "extra": {
    "stars": 2301,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-09-01T06:08:48Z",
    "language": "C++",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/InteractiveComputerGraphics/PositionBasedDynamics",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/InteractiveComputerGraphics/PositionBasedDynamics",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/InteractiveComputerGraphics/PositionBasedDynamics",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/InteractiveComputerGraphics/PositionBasedDynamics",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/InteractiveComputerGraphics/PositionBasedDynamics",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/InteractiveComputerGraphics/PositionBasedDynamics",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "interactivecomputergraphics2015interactivecomputergraphics"
  }
 ],
 "presets": [
  {
   "id": "xpbd-live",
   "title": "XPBD — stiff PBD alpha=0 (left) vs compliant XPBD elastic chain & strain heatmap (right)",
   "runtime": "glsl-fragment",
   "params": {
    "P_COMPLIANCE": 0.42,
    "P_GRAVITY": 1,
    "P_SPEED": 1,
    "P_SPLIT": 0.48
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_COMPLIANCE = 0.42; // P Compliance Alpha [0.0, 1.5, 0.02]\nconst float P_GRAVITY = 1.0; // P Gravity Load [0.2, 2.2, 0.05]\nconst float P_SPEED = 1.0; // P Osc Speed [0.0, 2.5, 0.05]\nconst float P_SPLIT = 0.48; // P PBD / XPBD Split [0.0, 1.0, 0.02]\n\nfloat sdSeg(vec2 p, vec2 a, vec2 b, out float h) {\n  vec2 pa = p - a;\n  vec2 ba = b - a;\n  h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);\n  return length(pa - ba * h);\n}\n\nvec3 strainRamp(float s) {\n  float t = clamp(s, 0.0, 1.0);\n  vec3 c0 = vec3(0.14, 0.62, 0.92);\n  vec3 c1 = vec3(0.18, 0.88, 0.62);\n  vec3 c2 = vec3(0.98, 0.72, 0.16);\n  vec3 c3 = vec3(0.96, 0.24, 0.22);\n  if (t < 0.33) return mix(c0, c1, t * 3.0);\n  if (t < 0.66) return mix(c1, c2, (t - 0.33) * 3.0);\n  return mix(c2, c3, (t - 0.66) * 3.0);\n}\n\n// Compute node position of a 7-node elastic XPBD chain with compliance alpha\nvec2 xpbdNode(int idx, float alpha, float grav, float t, float xOff) {\n  float fi = float(idx);\n  float restL = 0.105;\n  vec2 anchor = vec2(xOff, 0.36);\n  if (idx == 0) return anchor;\n\n  // Iterative XPBD equilibrium: dLambda = (-C - alphaTilde * lam) / (wSum + alphaTilde)\n  // Static stretch scales with alphaTilde * loadBelow; dynamic swing scales with compliance\n  float dt = 0.016;\n  float alphaTilde = alpha * 0.0018 / (dt * dt + 1e-5);\n  float wSum = 2.0;\n  float kComp = alphaTilde / (wSum + alphaTilde + 1e-5);\n\n  float swayPhase = t * (2.15 - 0.55 * kComp);\n  float wind = 0.11 * sin(swayPhase) + 0.045 * sin(swayPhase * 2.3 + 0.8);\n\n  vec2 pos = anchor;\n  for (int k = 1; k <= 7; k++) {\n    if (k > idx) break;\n    float fk = float(k);\n    float loadBelow = (8.0 - fk) * grav;\n    // XPBD analytical steady-state compliance elongation per link\n    float stretch = restL * (0.018 + 0.24 * kComp * loadBelow * 0.28);\n    float L = restL + stretch;\n    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);\n    pos += vec2(sin(ang), -cos(ang)) * L;\n  }\n  return pos;\n}\n\nvec3 aces(vec3 x) {\n  x = max(x, 0.0);\n  return (x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14);\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float px = 1.0 / max(iResolution.y, 1.0);\n  float screenX = fragCoord.x / max(iResolution.x, 1.0);\n  float split = clamp(P_SPLIT, 0.0, 1.0);\n  float alphaRight = max(P_COMPLIANCE, 0.0);\n  float grav = clamp(P_GRAVITY, 0.2, 2.5);\n  float t = iTime * max(P_SPEED, 0.0);\n\n  // Dark engineering blueprint grid\n  vec3 col = mix(vec3(0.028, 0.038, 0.058), vec3(0.055, 0.074, 0.112), smoothstep(-0.5, 0.5, uv.y));\n  vec2 g1 = abs(fract(uv * 10.0 - 0.5) - 0.5);\n  vec2 g2 = abs(fract(uv * 2.0 - 0.5) - 0.5);\n  col += vec3(0.016, 0.024, 0.038) * smoothstep(0.035, 0.008, min(g1.x, g1.y));\n  col += vec3(0.028, 0.042, 0.068) * smoothstep(0.014, 0.003, min(g2.x, g2.y));\n\n  // Top ceiling beam\n  float dBeam = abs(uv.y - 0.385) - 0.025;\n  col = mix(col, vec3(0.16, 0.20, 0.27), smoothstep(px * 2.0, 0.0, dBeam));\n  float hatch = smoothstep(0.45, 0.55, sin((uv.x + uv.y) * 90.0));\n  col = mix(col, vec3(0.24, 0.30, 0.39), smoothstep(px * 2.0, 0.0, dBeam) * hatch * 0.45);\n\n  // Draw two chains on each side (stiff left alpha=0, compliant right alpha=P_COMPLIANCE)\n  float restL = 0.105;\n  for (int side = 0; side < 2; side++) {\n    bool isRight = (side == 1);\n    float alpha = isRight ? alphaRight : 0.0;\n    float xBase = isRight ? 0.34 : -0.34;\n    float sideMask = isRight ? smoothstep(split - 0.004, split + 0.004, screenX) : smoothstep(split + 0.004, split - 0.004, screenX);\n\n    // Draw two coupled strands forming a narrow compliant ladder/ribbon\n    for (int strand = 0; strand < 2; strand++) {\n      float dx = (strand == 0) ? -0.095 : 0.095;\n      vec2 prevP = xpbdNode(0, alpha, grav, t + float(strand) * 0.18, xBase + dx);\n      vec2 prevRest = vec2(xBase + dx, 0.36);\n\n      for (int i = 1; i <= 7; i++) {\n        vec2 curP = xpbdNode(i, alpha, grav, t + float(strand) * 0.18, xBase + dx);\n        vec2 curRest = vec2(xBase + dx, 0.36 - float(i) * restL);\n\n        // Rest-length ghost guide\n        float hGhost;\n        float dGhost = sdSeg(uv, prevRest, curRest, hGhost);\n        float dash = step(0.5, fract(hGhost * 4.0));\n        col += vec3(0.16, 0.22, 0.32) * smoothstep(px * 2.2, px * 0.5, dGhost) * dash * 0.45 * sideMask;\n\n        // Elastic constraint spring segment\n        float hSeg;\n        float dSeg = sdSeg(uv, prevP, curP, hSeg);\n        float segLen = length(curP - prevP);\n        float strain = clamp((segLen - restL) / (restL * 0.38), 0.0, 1.0);\n        vec3 sCol = strainRamp(strain);\n\n        // Coiled spring wave modulation along the segment\n        vec2 dir = (curP - prevP) / max(segLen, 1e-5);\n        vec2 perp = vec2(-dir.y, dir.x);\n        float coils = sin(hSeg * 6.2831853 * 6.0) * (0.011 - 0.004 * strain);\n        vec2 springPt = mix(prevP, curP, hSeg) + perp * coils * smoothstep(0.0, 0.12, hSeg) * smoothstep(1.0, 0.88, hSeg);\n        float dSpring = length(uv - springPt);\n\n        float linkCore = smoothstep(0.0085, 0.003, dSeg);\n        float coilGlow = smoothstep(0.007, 0.002, dSpring);\n        col = mix(col, sCol * 1.15, max(linkCore * 0.72, coilGlow * 0.92) * sideMask);\n\n        // Horizontal shear rung between the two strands\n        if (strand == 1) {\n          vec2 leftP = xpbdNode(i, alpha, grav, t, xBase - 0.095);\n          float hRung;\n          float dRung = sdSeg(uv, leftP, curP, hRung);\n          float rungStrain = clamp(abs(length(curP - leftP) - 0.19) / 0.08, 0.0, 1.0);\n          col = mix(col, strainRamp(rungStrain) * 0.85, smoothstep(0.006, 0.002, dRung) * 0.75 * sideMask);\n        }\n\n        // Mass node sphere + compliance energy halo\n        float rNode = (i == 7) ? 0.028 : 0.019;\n        float dNode = length(uv - curP);\n        if (dNode < rNode) {\n          vec2 local = (uv - curP) / rNode;\n          float z = sqrt(max(1.0 - dot(local, local), 0.0));\n          vec3 n = normalize(vec3(local, z));\n          float diff = max(dot(n, normalize(vec3(0.45, 0.7, 0.6))), 0.0);\n          float spec = pow(max(dot(n, normalize(vec3(0.3, 0.5, 1.0))), 0.0), 32.0);\n          vec3 nodeCol = mix(vec3(0.75, 0.84, 0.96), sCol, 0.45) * (0.35 + 0.75 * diff) + vec3(0.95) * spec * 0.7;\n          col = mix(col, nodeCol, sideMask);\n        }\n        float halo = smoothstep(rNode + 0.016, rNode, dNode) * smoothstep(rNode - 0.002, rNode + 0.004, dNode);\n        col += sCol * halo * (0.35 + 0.65 * strain) * sideMask;\n\n        prevP = curP;\n        prevRest = curRest;\n      }\n\n      // Anchor pin\n      float dPin = length(uv - vec2(xBase + dx, 0.36));\n      col = mix(col, vec3(0.95, 0.82, 0.36), smoothstep(0.018, 0.011, dPin) * sideMask);\n    }\n  }\n\n  // Split divider line\n  float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));\n  col = mix(col, vec3(0.94, 0.97, 1.0), sep);\n\n  fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-30",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "xpbd",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:53:38.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.3417,
      "std": 0.1749,
      "min": 0.1968,
      "max": 0.9398
     },
     "image": "/specimens/xpbd-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "position-based-dynamics",
  "soft-step-solver",
  "vertex-block-descent",
  "unified-particle-physics"
 ],
 "extends": [
  "position-based-dynamics"
 ],
 "supersedes": [
  "position-based-dynamics"
 ],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/simulation/xpbd.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Macklin et al., 2016",
 "url": "https://texelatlas.vercel.app/t/xpbd/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 145.23,
  "tier": "extreme",
  "p50_ms": 4.5021,
  "p95_ms": 4.7383,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 36,
  "preset_id": "xpbd-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 129.82,
   "tier": "extreme",
   "p50_ms": 2.0641,
   "p95_ms": 2.1193,
   "speedup_x": 2.18,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 101.55,
   "tier": "extreme",
   "p50_ms": 2.9245,
   "p95_ms": 2.925,
   "speedup_x": 1.54,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}