---
id: "sdf-collision-local-optimization"
title: "Local Optimization for Robust SDF Collision"
aliases: [SDF Rigid-Body Collision]
domain: "simulation"
stage: "simulation"
realtime: "realtime"
platforms: [cuda, desktop-gpu, webgpu]
year_introduced: 2020
inputs: [mesh, sdf]
outputs: [animation, mesh]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Macklin et al., 2020"
url: "https://texelatlas.vercel.app/t/sdf-collision-local-optimization/"
sources_verified_at: "2026-12-02"
---
# Local Optimization for Robust SDF Collision (Macklin et al., 2020)

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

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

cheap — 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

## Dataflow

- Inputs: mesh, sdf
- Outputs: animation, mesh
- Platforms: cuda, desktop-gpu, webgpu

## Presets

### SDF Collision — continuous distance field iso-contours with closest-point contact projection (glsl-fragment; rendered 2026-12-02)

```json
{
  "P_BOUNCE": 0.65,
  "P_RADIUS": 0.22
}
```

```glsl
const float P_BOUNCE = 0.65; // P Drop Speed [0.1, 1.8, 0.05]
const float P_RADIUS = 0.22; // P Body Radius [0.12, 0.34, 0.01]

float sdBowl(vec2 p) {
  float d1 = abs(length(p - vec2(0.0, 0.18)) - 0.62) - 0.04;
  float box = max(abs(p.x) - 0.85, p.y - 0.05);
  return max(d1, -box);
}
vec2 gradBowl(vec2 p) {
  float e = 0.002;
  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))));
}

void mainImage(out vec4 fragColor, in vec2 fragCoord) {
  vec2 uv = (fragCoord - 0.5 * iResolution.xy) / iResolution.y;
  float d = sdBowl(uv);
  // Iso-distance contour field
  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));
  col = mix(col, vec3(0.86, 0.82, 0.74), smoothstep(0.012, 0.003, abs(d)));
  // Animated rigid circle with local closest-point contact projection
  float t = iTime * P_BOUNCE;
  vec2 c = vec2(sin(t) * 0.32, -0.18 + abs(cos(t * 1.4)) * 0.35);
  float distC = sdBowl(c);
  vec2 n = gradBowl(c);
  if (distC < P_RADIUS) c += n * (P_RADIUS - distC);
  vec2 cp = c - n * sdBowl(c);
  float body = smoothstep(P_RADIUS + 0.006, P_RADIUS - 0.006, length(uv - c));
  col = mix(col, vec3(0.95, 0.52, 0.24), body * 0.9);
  float cpDot = smoothstep(0.024, 0.012, length(uv - cp));
  col = mix(col, vec3(0.35, 0.98, 0.62), cpDot);
  fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}
```

Attribution: MIT — written for this index.

## Lineage

- extends [Extended Position-Based Dynamics](https://texelatlas.vercel.app/t/xpbd.md)

## Sources

1. [primary] Miles Macklin, Kenny Erleben, Matthias Müller, Nuttapong Chentanez, Stefan Jeschke, Zach Corse (2020) Local Optimization for Robust Signed Distance Field Collision. Proceedings of the ACM on Computer Graphics and Interactive Techniques. https://doi.org/10.1145/3384538 (verified via crossref on 2026-12-02)

## Cite this entry

Texel. "Local Optimization for Robust SDF Collision." https://texelatlas.vercel.app/t/sdf-collision-local-optimization/ (accessed 2026-12-02).
