{
 "id": "sdf-collision-local-optimization",
 "title": "Local Optimization for Robust SDF Collision",
 "aliases": [
  "SDF Rigid-Body Collision"
 ],
 "domain": "simulation",
 "subdomain": "collision",
 "stage": "simulation",
 "realtime": "realtime",
 "platforms": [
  "cuda",
  "desktop-gpu",
  "webgpu"
 ],
 "year_introduced": 2020,
 "inputs": [
  "mesh",
  "sdf"
 ],
 "outputs": [
  "animation",
  "mesh"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Finds exact deepest-penetration contact points between arbitrary triangle meshes and signed distance fields using fast per-triangle Frank-Wolfe local optimization, enabling robust GPU rigid-body physics without convex hull decomposition.",
 "how_it_works": "Naive vertex-against-SDF collision misses edge-edge and face-face penetrations when large triangles collide with curved or sharp SDF features. Macklin et al. formulate contact detection for each triangle-SDF pair as minimizing the SDF value over the triangle's barycentric domain via a few iterations of Frank-Wolfe / projected gradient descent on the GPU. This locates true deepest-penetration interior and edge contacts smoothly in constant time per triangle without subdividing meshes or authoring manual convex hulls.",
 "when_to_use": "Use for real-time GPU rigid-body simulation, cloth-against-environment contact, or destructible geometry where arbitrary concave meshes collide cleanly against static or dynamic SDFs.",
 "cost": {
  "class": "cheap",
  "notes": "A handful of SDF trilinear texture fetches per candidate triangle on the GPU; parallelizes trivially."
 },
 "failure_modes": [
  "SDF voxel grid resolution limits thin-wall accuracy unless paired with narrow-band/sparse grids",
  "Non-convex local minima inside a single huge triangle may still require coarse triangle subdivision",
  "Static SDF baking assumes non-deforming collider shapes"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1145/3384538",
   "type": "paper",
   "title": "Local Optimization for Robust Signed Distance Field Collision",
   "authors": [
    "Miles Macklin",
    "Kenny Erleben",
    "Matthias Müller",
    "Nuttapong Chentanez",
    "Stefan Jeschke",
    "Zach Corse"
   ],
   "year": 2020,
   "venue": "Proceedings of the ACM on Computer Graphics and Interactive Techniques",
   "url": "https://doi.org/10.1145/3384538",
   "ids": {
    "doi": "10.1145/3384538"
   },
   "license": null,
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145%2F3384538",
     "checked_at": "2026-12-02T02:40:24.869Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145%2F3384538",
     "checked_at": "2026-12-02T02:40:24.869Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145%2F3384538",
     "checked_at": "2026-12-02T02:40:24.869Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145%2F3384538",
     "checked_at": "2026-12-02T02:40:24.869Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1145%2F3384538",
     "checked_at": "2026-12-02T02:40:24.869Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-12-02T02:40:24.869Z",
   "title_sim": 1,
   "__bib": "macklin2020local"
  }
 ],
 "presets": [
  {
   "id": "sdf-collision-local-optimization-live",
   "title": "SDF Collision — continuous distance field iso-contours with closest-point contact projection",
   "runtime": "glsl-fragment",
   "params": {
    "P_BOUNCE": 0.65,
    "P_RADIUS": 0.22
   },
   "basis": "original",
   "license_note": "MIT — written for this index.",
   "code": "const float P_BOUNCE = 0.65; // P Drop Speed [0.1, 1.8, 0.05]\nconst float P_RADIUS = 0.22; // P Body Radius [0.12, 0.34, 0.01]\n\nfloat sdBowl(vec2 p) {\n  float d1 = abs(length(p - vec2(0.0, 0.18)) - 0.62) - 0.04;\n  float box = max(abs(p.x) - 0.85, p.y - 0.05);\n  return max(d1, -box);\n}\nvec2 gradBowl(vec2 p) {\n  float e = 0.002;\n  return normalize(vec2(sdBowl(p + vec2(e, 0.0)) - sdBowl(p - vec2(e, 0.0)), sdBowl(p + vec2(0.0, e)) - sdBowl(p - vec2(0.0, e))));\n}\n\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;\n  float d = sdBowl(uv);\n  // Iso-distance contour field\n  vec3 col = mix(vec3(0.05, 0.08, 0.14), vec3(0.14, 0.22, 0.34), 0.5 + 0.5 * sin(d * 60.0));\n  col = mix(col, vec3(0.86, 0.82, 0.74), smoothstep(0.012, 0.003, abs(d)));\n  // Animated rigid circle with local closest-point contact projection\n  float t = iTime * P_BOUNCE;\n  vec2 c = vec2(sin(t) * 0.32, -0.18 + abs(cos(t * 1.4)) * 0.35);\n  float distC = sdBowl(c);\n  vec2 n = gradBowl(c);\n  if (distC < P_RADIUS) c += n * (P_RADIUS - distC);\n  vec2 cp = c - n * sdBowl(c);\n  float body = smoothstep(P_RADIUS + 0.006, P_RADIUS - 0.006, length(uv - c));\n  col = mix(col, vec3(0.95, 0.52, 0.24), body * 0.9);\n  float cpDot = smoothstep(0.024, 0.012, length(uv - cp));\n  col = mix(col, vec3(0.35, 0.98, 0.62), cpDot);\n  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);\n}",
   "execution_fidelity": "faithful-pass",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-12-02",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "sdf-collision-local-optimization",
     "runtime": "glsl-fragment",
     "checked_at": "2026-12-02T02:47:19.890Z",
     "execution_fidelity": "faithful-pass",
     "benchmark_eligible": true,
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime∈{0.0,1.5,4.0}",
     "stats": {
      "mean": 0.4598,
      "std": 0.1371,
      "unique_colors": 138,
      "nan_pixels": 0,
      "animated": true,
      "anim_delta": 0.0479
     },
     "image": "/specimens/sdf-collision-local-optimization-live.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "xpbd",
  "sphere-tracing",
  "mpm-snow"
 ],
 "extends": [
  "xpbd"
 ],
 "supersedes": [],
 "combines_with": [],
 "provenance": {
  "prose": "original text written for this index (frontier expansion, authority-verified)",
  "sources_verified_at": "2026-12-02T02:40:24.869Z"
 },
 "solves": [],
 "authority": "Macklin et al., 2020",
 "url": "https://texelatlas.vercel.app/t/sdf-collision-local-optimization/",
 "execution_fidelity": "faithful-pass",
 "fidelity_label": "Faithful Pass",
 "benchmark_eligible": true
}