{
 "id": "position-based-dynamics",
 "title": "Position Based Dynamics",
 "aliases": [
  "PBD"
 ],
 "domain": "simulation",
 "subdomain": "particle/constraint solvers",
 "stage": "simulation",
 "realtime": "realtime",
 "platforms": [
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cpu",
  "unity",
  "unreal"
 ],
 "year_introduced": 2007,
 "inputs": [
  "particles"
 ],
 "outputs": [
  "particles",
  "mesh"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "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.",
 "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": "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 `xpbd` 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` when you need physically calibrated cloth with large steps on CPU. Prefer `verlet-integration-constraints` for the simplest ropes and ragdolls.",
 "cost": {
  "class": "medium",
  "notes": "Linear in constraints x iterations; massively parallel with graph colouring or Jacobi. Qualitative only."
 },
 "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"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1016/j.jvcir.2007.01.005",
   "type": "paper",
   "title": "Position based dynamics",
   "authors": [
    "Matthias Müller",
    "Bruno Heidelberger",
    "Marcus Hennix",
    "John Ratcliff"
   ],
   "year": 2007,
   "venue": "Journal of Visual Communication and Image Representation",
   "url": "https://doi.org/10.1016/j.jvcir.2007.01.005",
   "ids": {
    "doi": "10.1016/j.jvcir.2007.01.005"
   },
   "license": null,
   "extra": {
    "csl_type": "journal-article"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/j.jvcir.2007.01.005",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/j.jvcir.2007.01.005",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/j.jvcir.2007.01.005",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/j.jvcir.2007.01.005",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1016/j.jvcir.2007.01.005",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "mller2007position"
  },
  {
   "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"
  },
  {
   "role": "tutorial",
   "key": "url:https://matthias-research.github.io/pages/tenMinutePhysics",
   "type": "tutorial",
   "title": "Ten Minute Physics",
   "authors": [
    "Matthias Müller"
   ],
   "year": null,
   "venue": "matthias-research.github.io",
   "url": "https://matthias-research.github.io/pages/tenMinutePhysics",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20260924155100/https://matthias-research.github.io/pages/tenMinutePhysics/",
     "timestamp": "20260924155100"
    },
    "page_title": "Ten Minute Physics",
    "host": "matthias-research.github.io",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://matthias-research.github.io/pages/tenMinutePhysics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://matthias-research.github.io/pages/tenMinutePhysics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "http",
     "endpoint": "GET https://matthias-research.github.io/pages/tenMinutePhysics → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "research-draft",
     "endpoint": "title_hint/author_hint, checked against page title where available",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "mllerminute"
  }
 ],
 "presets": [
  {
   "id": "position-based-dynamics-live",
   "title": "Position Based Dynamics — real-time iterative Gauss-Seidel distance constraint solver & collider projection",
   "runtime": "glsl-fragment",
   "params": {
    "P_ITERATIONS": 8,
    "P_STIFFNESS": 0.92,
    "P_GRAVITY": 1,
    "P_COLLIDER_SPEED": 1
   },
   "basis": "original",
   "license_note": "Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).",
   "code": "const float P_ITERATIONS = 8.0; // P Solver Iters [1.0, 14.0, 1.0]\nconst float P_STIFFNESS = 0.92; // P Stiffness k [0.2, 1.0, 0.02]\nconst float P_GRAVITY = 1.0; // P Gravity [0.2, 2.0, 0.05]\nconst float P_COLLIDER_SPEED = 1.0; // P Collider Speed [0.0, 2.5, 0.05]\n\nfloat sdSegment(vec2 p, vec2 a, vec2 b) {\n  vec2 pa = p - a, ba = b - a;\n  float h = clamp(dot(pa, ba) / max(dot(ba, ba), 1e-5), 0.0, 1.0);\n  return length(pa - ba * h);\n}\n\nvec3 strainColor(float s) {\n  s = clamp(s, 0.0, 1.0);\n  vec3 c0 = vec3(0.14, 0.82, 0.92);\n  vec3 c1 = vec3(0.98, 0.80, 0.22);\n  vec3 c2 = vec3(1.00, 0.24, 0.34);\n  if (s < 0.5) return mix(c0, c1, s * 2.0);\n  return mix(c1, c2, (s - 0.5) * 2.0);\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 tAnim = iTime * max(P_COLLIDER_SPEED, 0.0);\n  int nIter = int(clamp(floor(P_ITERATIONS + 0.5), 1.0, 14.0));\n  float stiff = clamp(P_STIFFNESS, 0.15, 1.0);\n  float grav = clamp(P_GRAVITY, 0.15, 2.2);\n\n  // Moving rigid spherical collider pressing into a 11-node pinned PBD chain\n  vec2 collPos = vec2(0.28 * sin(tAnim * 0.72), -0.05 + 0.16 * cos(tAnim * 1.05));\n  float collRad = 0.175;\n\n  // Initialize 11 PBD particles with unconstrained predicted positions x* = x + dt*v + dt^2*g\n  vec2 pos[11];\n  float restLen = 0.132;\n  vec2 pinL = vec2(-0.62, 0.28);\n  vec2 pinR = vec2(0.62, 0.28);\n  for (int i = 0; i < 11; i++) {\n    float u = float(i) / 10.0;\n    float sag = sin(u * 3.14159265) * (0.42 * grav);\n    float sway = sin(u * 6.28318 + tAnim * 1.4) * 0.03 * sin(u * 3.14159);\n    pos[i] = mix(pinL, pinR, u) + vec2(sway, -sag);\n  }\n\n  // Genuine Position Based Dynamics iterative constraint projection loop (Gauss-Seidel)\n  for (int it = 0; it < 14; it++) {\n    if (it >= nIter) break;\n    // Distance constraints C(p_i, p_{i+1}) = |p_{i+1} - p_i| - d = 0\n    for (int i = 0; i < 10; i++) {\n      vec2 delta = pos[i + 1] - pos[i];\n      float len = max(length(delta), 1e-5);\n      float diff = (len - restLen) / len;\n      vec2 corr = delta * diff * 0.5 * stiff;\n      if (i > 0) pos[i] += corr;\n      if (i + 1 < 10) pos[i + 1] -= corr;\n    }\n    // Inequality collision constraint C_col(p_i) = |p_i - c| - R >= 0\n    for (int i = 1; i < 10; i++) {\n      vec2 dc = pos[i] - collPos;\n      float d = length(dc);\n      if (d < collRad + 0.022) {\n        pos[i] = collPos + (dc / max(d, 1e-5)) * (collRad + 0.022);\n      }\n      // Subtle bending smoothing between neighbors\n      if (i > 1 && i < 9) {\n        vec2 mid = 0.5 * (pos[i - 1] + pos[i + 1]);\n        pos[i] = mix(pos[i], mid, 0.04 * stiff);\n      }\n    }\n    pos[0] = pinL;\n    pos[10] = pinR;\n  }\n\n  // Technical studio blueprint background\n  vec3 col = mix(vec3(0.03, 0.04, 0.065), vec3(0.065, 0.085, 0.125), smoothstep(-0.5, 0.5, uv.y));\n  vec2 g = abs(fract(uv * 10.0 - 0.5) - 0.5);\n  col += vec3(0.022, 0.032, 0.048) * smoothstep(0.03, 0.005, min(g.x, g.y));\n\n  // Unconstrained predicted parabolic curve (ghost reference showing gravity before PBD projection)\n  float dGhost = 1e5;\n  for (int i = 0; i < 10; i++) {\n    float u0 = float(i) / 10.0;\n    float u1 = float(i + 1) / 10.0;\n    vec2 g0 = mix(pinL, pinR, u0) + vec2(0.0, -sin(u0 * 3.14159265) * 0.42 * grav);\n    vec2 g1 = mix(pinL, pinR, u1) + vec2(0.0, -sin(u1 * 3.14159265) * 0.42 * grav);\n    dGhost = min(dGhost, sdSegment(uv, g0, g1));\n  }\n  float dash = step(0.45, fract((uv.x + 1.0) * 18.0));\n  col = mix(col, vec3(0.28, 0.36, 0.50), smoothstep(px * 2.5, px * 0.6, dGhost) * 0.55 * dash);\n\n  // Shaded rigid sphere collider with contact halo\n  float dColl = length(uv - collPos) - collRad;\n  if (dColl < 0.0) {\n    vec2 rel = (uv - collPos) / collRad;\n    float nz = sqrt(max(1.0 - dot(rel, rel), 0.0));\n    vec3 cn = normalize(vec3(rel, nz));\n    float cDiff = max(dot(cn, normalize(vec3(0.55, 0.72, 0.65))), 0.0);\n    float cSpec = pow(max(dot(cn, normalize(vec3(0.45, 0.65, 0.85))), 0.0), 36.0);\n    col = vec3(0.14, 0.19, 0.28) * (0.32 + 0.85 * cDiff) + vec3(0.75, 0.86, 1.0) * cSpec * 0.48;\n  }\n  col = mix(col, vec3(0.42, 0.72, 1.0), smoothstep(px * 3.2, px * 0.6, abs(dColl)) * 0.75);\n\n  // Draw PBD constraint edges colored by residual stretch strain | |p_j - p_i| - d | / d\n  for (int i = 0; i < 10; i++) {\n    float segLen = length(pos[i + 1] - pos[i]);\n    float strain = abs(segLen - restLen) / max(restLen * 0.28, 1e-4);\n    float dSeg = sdSegment(uv, pos[i], pos[i + 1]);\n    vec3 eCol = strainColor(strain);\n    col += eCol * exp(-dSeg * 75.0) * 0.35;\n    col = mix(col, eCol, smoothstep(0.011, 0.004, dSeg));\n  }\n\n  // Draw PBD mass nodes (pinned anchors in gold, dynamic nodes in ivory/cyan)\n  for (int i = 0; i < 11; i++) {\n    float dp = length(uv - pos[i]);\n    bool isPin = (i == 0 || i == 10);\n    float rad = isPin ? 0.026 : 0.020;\n    vec3 nCol = isPin ? vec3(1.0, 0.78, 0.24) : vec3(0.92, 0.96, 1.0);\n    col = mix(col, vec3(0.05, 0.07, 0.10), smoothstep(rad + 0.007, rad + 0.001, dp));\n    col = mix(col, nCol, smoothstep(rad, rad - 0.005, dp));\n  }\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": "position-based-dynamics",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-30T19:04:36.000Z",
     "renderer": "Headless EGL Tesla T4/PCIe/SSE2, OpenGL 3.30 Core, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.3254,
      "std": 0.1196,
      "min": 0.2055,
      "max": 0.9006
     },
     "image": "/specimens/position-based-dynamics-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "xpbd",
  "verlet-integration-constraints",
  "vertex-block-descent",
  "shape-matching-deformation",
  "position-based-fluids"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "linear-blend-skinning",
   "why": "PBD cloth or soft bodies simulate secondary motion on top of a skinned character's skeleton-driven positions"
  }
 ],
 "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/position-based-dynamics.json"
 },
 "solves": [
  "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"
 ],
 "authority": "Müller et al., 2007",
 "url": "https://texelatlas.vercel.app/t/position-based-dynamics/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 57.22,
  "tier": "heavy",
  "p50_ms": 1.7966,
  "p95_ms": 1.8616,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "position-based-dynamics-live",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 50.13,
   "tier": "heavy",
   "p50_ms": 0.7921,
   "p95_ms": 0.7956,
   "speedup_x": 2.27,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 40.27,
   "tier": "heavy",
   "p50_ms": 1.1597,
   "p95_ms": 1.1602,
   "speedup_x": 1.55,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}