---
id: "deepsdf-neural-sdf"
title: "DeepSDF (neural signed distance functions)"
aliases: [DeepSDF, auto-decoder SDF, neural SDF]
domain: "geometry"
stage: "geometry"
realtime: "offline"
platforms: [cuda, python]
year_introduced: 2019
inputs: [sdf, point-cloud]
outputs: [sdf, mesh]
style: "both"
dynamic: "static"
cost: "offline"
authority: "Park et al., 2019"
url: "https://texelatlas.vercel.app/t/deepsdf-neural-sdf/"
sources_verified_at: "2026-11-29"
---
# DeepSDF (neural signed distance functions) (Park et al., 2019)

> A network that takes a 3D point and a per-shape latent code and returns signed distance, so a whole shape category lives in one decoder and shapes are recovered by optimising their latent code.

## Reach for it when

- want a neural network that outputs a shape from a latent code
- complete a partial scan into a full shape
- interpolate between two shapes smoothly
- learn a shape prior for a whole object category

## How it works

Train a single MLP f(z, x) whose output is the signed distance at point x for the shape described by code z. Training data is sampled SDF values near and far from each training shape's surface, with the output clamped near the surface to focus capacity. There is no encoder: every training shape owns a learnable latent vector, and codes and decoder weights are optimised together (an auto-decoder). At test time, with the weights fixed, you fit a new latent code by gradient descent so predicted distances match observed samples, which may be sparse or partial. Interpolating between codes morphs shapes. Extract the surface by evaluating on a grid and running [Marching Cubes](https://texelatlas.vercel.app/t/marching-cubes.md), or by sphere tracing the field. Shape completion from partial scans works because the decoder encodes a prior over plausible shapes.

## When to use it

Choose it as the reference design for learned SDF shape priors, shape completion from partial depth, and latent-space interpolation within a category. Prefer [Poisson Surface Reconstruction](https://texelatlas.vercel.app/t/poisson-surface-reconstruction.md) when you have dense oriented points and no prior is wanted, [NeuS](https://texelatlas.vercel.app/t/neus.md) or [Neuralangelo](https://texelatlas.vercel.app/t/neuralangelo.md) when the supervision is multi-view photos, and [Instant NGP (Multiresolution Hash Encoding)](https://texelatlas.vercel.app/t/instant-ngp.md)-style hash grids when a single scene must be fit fast rather than a category generalised.

## Cost

offline — Training takes hours on a GPU for a category; inference per point is one MLP forward pass, so a dense grid is slow compared with classic meshing.
Measured GPU Weight: 27.55× baseline (heavy) — 0.8539 ms median / 0.8728 ms p95 on Tesla T4/PCIe/SSE2 @ 1920x1080 (opengl-timer-query).
Ada L4 scaling: 25.31× baseline (heavy) — 0.4025 ms median (2.12× faster on L4).
Ampere A100 scaling: 17.25× baseline (moderate) — 0.4967 ms median (1.72× faster on A100).

## Failure modes

- Fine detail and thin structures are lost because one MLP and a small code must cover the whole category
- Out-of-category inputs decode to a blobby average shape
- Latent-code fitting on partial data has local minima and needs good initialisation
- The SDF is not guaranteed to be a true distance field, which breaks sphere-tracing step sizes and gradient-norm assumptions

## Dataflow

- Inputs: sdf, point-cloud
- Outputs: sdf, mesh
- Platforms: cuda, python

## Presets

### DeepSDF Neural Implicit — latent-space shape interpolation & signed-distance iso-contour slice (glsl-fragment; rendered 2026-11-30)

```json
{
  "P_LATENT_Z": 0.5,
  "P_SLICE_Y": -0.22,
  "P_ISO_FREQ": 14,
  "P_ROT_SPEED": 0.65
}
```

```glsl
const float P_LATENT_Z = 0.50; // P Latent Code z [0.0, 1.0, 0.02]
const float P_SLICE_Y = -0.22; // P SDF Slice Height [-0.55, 0.45, 0.02]
const float P_ISO_FREQ = 14.0; // P Iso-Ring Density [6.0, 26.0, 1.0]
const float P_ROT_SPEED = 0.65; // P Spin Speed [0.0, 2.0, 0.05]

mat2 rot2(float a) { float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }

float sdBox(vec3 p, vec3 b) {
  vec3 q = abs(p) - b;
  return length(max(q, 0.0)) + min(max(q.x, max(q.y, q.z)), 0.0);
}

float sdTorus(vec3 p, vec2 t) {
  vec2 q = vec2(length(p.xz) - t.x, p.y);
  return length(q) - t.y;
}

// Latent-conditioned implicit shape f_theta(x, z) smoothly morphing across a 3-shape manifold
float evalDeepSDF(vec3 p, float zCode) {
  // Shape 0: Chamfered architectural chair/frame
  float dSeat = sdBox(p - vec3(0.0, -0.10, 0.0), vec3(0.42, 0.09, 0.42)) - 0.04;
  float dBack = sdBox(p - vec3(0.0, 0.28, -0.34), vec3(0.42, 0.34, 0.08)) - 0.04;
  float dLegs = sdBox(vec3(abs(p.x) - 0.32, p.y + 0.36, abs(p.z) - 0.32), vec3(0.07, 0.24, 0.07)) - 0.02;
  float sChair = min(min(dSeat, dBack), dLegs);

  // Shape 1: Smooth torus-sphere sculpture
  float sTorus = min(sdTorus(p.xzy, vec2(0.42, 0.16)), length(p) - 0.26);

  // Shape 2: Hollowed rounded cube with cylindrical cutouts
  float sCube = max(sdBox(p, vec3(0.46)) - 0.06, -(min(min(length(p.xy), length(p.yz)), length(p.xz)) - 0.27));

  float u = clamp(zCode, 0.0, 1.0) * 2.0;
  float d = (u < 1.0) ? mix(sChair, sTorus, smoothstep(0.0, 1.0, u)) : mix(sTorus, sCube, smoothstep(0.0, 1.0, u - 1.0));
  // Subtle neural MLP sinusoidal smoothness characteristic of continuous latent decoding
  return d + 0.012 * sin(p.x * 7.0) * sin(p.y * 7.0) * sin(p.z * 7.0) * sin(zCode * 3.1415926);
}

vec3 calcNormal(vec3 p, float zCode, float spin) {
  vec2 e = vec2(0.0022, 0.0);
  vec3 qx1 = p + e.xyy; qx1.xz = rot2(spin) * qx1.xz;
  vec3 qx0 = p - e.xyy; qx0.xz = rot2(spin) * qx0.xz;
  vec3 qy1 = p + e.yxy; qy1.xz = rot2(spin) * qy1.xz;
  vec3 qy0 = p - e.yxy; qy0.xz = rot2(spin) * qy0.xz;
  vec3 qz1 = p + e.yyx; qz1.xz = rot2(spin) * qz1.xz;
  vec3 qz0 = p - e.yyx; qz0.xz = rot2(spin) * qz0.xz;
  return normalize(vec3(
    evalDeepSDF(qx1, zCode) - evalDeepSDF(qx0, zCode),
    evalDeepSDF(qy1, zCode) - evalDeepSDF(qy0, zCode),
    evalDeepSDF(qz1, zCode) - evalDeepSDF(qz0, zCode)
  ));
}

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 spin = iTime * max(P_ROT_SPEED, 0.0) * 0.55;
  // Blend user latent code with gentle automatic latent-space traversal
  float zCode = clamp(fract(P_LATENT_Z + 0.18 * sin(iTime * 0.45)), 0.0, 1.0);
  float sliceY = clamp(P_SLICE_Y, -0.58, 0.48);
  float isoFreq = clamp(P_ISO_FREQ, 5.0, 28.0);

  vec3 ro = vec3(0.0, 0.72, 2.38);
  vec3 ta = vec3(0.0, -0.06, 0.0);
  vec3 fwd = normalize(ta - ro);
  vec3 right = normalize(cross(fwd, vec3(0.0, 1.0, 0.0)));
  vec3 up = cross(right, fwd);
  vec3 rd = normalize(fwd * 1.55 + right * uv.x + up * uv.y);

  vec3 col = mix(vec3(0.024, 0.034, 0.056), vec3(0.070, 0.092, 0.144), smoothstep(-0.55, 0.55, uv.y));

  // Intersect horizontal SDF iso-contour inspection plane at y = sliceY
  float tPlane = (abs(rd.y) > 0.001) ? ((sliceY - ro.y) / rd.y) : 1e5;
  if (tPlane < 0.0) tPlane = 1e5;

  // Raymarch the zero-level set f_theta(x, z) = 0
  float tHit = 0.0;
  bool hitShape = false;
  for (int i = 0; i < 68; i++) {
    vec3 p = ro + rd * tHit;
    vec3 q = p;
    q.xz = rot2(spin) * q.xz;
    float d = evalDeepSDF(q, zCode);
    if (d < 0.002) { hitShape = true; break; }
    tHit += d * 0.85;
    if (tHit > 7.5) break;
  }

  // Render translucent SDF slice plane first if behind or intersecting
  if (tPlane < 7.5 && (!hitShape || tPlane < tHit)) {
    vec3 sp = ro + rd * tPlane;
    if (length(sp.xz) < 1.38) {
      vec3 sq = sp;
      sq.xz = rot2(spin) * sq.xz;
      float sdf = evalDeepSDF(sq, zCode);
      // Classic positive (cool blue) / negative (warm orange) signed-distance contour map
      vec3 sCol = (sdf > 0.0) ? vec3(0.14, 0.58, 0.92) : vec3(0.96, 0.44, 0.18);
      sCol *= 0.82 - exp(-4.5 * abs(sdf)) * 0.42;
      float rings = 0.72 + 0.28 * cos(sdf * isoFreq * 6.2831853);
      sCol *= rings;
      // Crisp white zero-level set contour f(x,z) = 0
      sCol = mix(sCol, vec3(0.98, 0.99, 1.0), smoothstep(0.022, 0.004, abs(sdf)));
      float diskMask = smoothstep(1.38, 1.24, length(sp.xz));
      col = mix(col, sCol, diskMask * 0.78);
    }
  }

  // Render neural implicit surface (above slice plane or in front of it)
  if (hitShape) {
    vec3 p = ro + rd * tHit;
    vec3 n = calcNormal(p, zCode, spin);
    vec3 l1 = normalize(vec3(0.55, 0.85, 0.52));
    vec3 l2 = normalize(vec3(-0.70, -0.25, 0.48));
    float diff = max(dot(n, l1), 0.0) * 0.85 + max(dot(n, l2), 0.0) * 0.26;
    float spec = pow(max(dot(n, normalize(l1 - rd)), 0.0), 52.0);
    float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0);

    vec3 alb = mix(vec3(0.24, 0.76, 0.86), vec3(0.88, 0.62, 0.96), zCode);
    vec3 surfCol = alb * (0.24 + 0.85 * diff) + vec3(0.98) * spec * 0.58 + vec3(0.48, 0.80, 1.0) * rim * 0.34;

    // Highlight intersection seam where slice plane cuts the zero-level surface
    float cutRing = smoothstep(0.022, 0.004, abs(p.y - sliceY));
    surfCol = mix(surfCol, vec3(1.0, 0.94, 0.46), cutRing * 0.90);

    if (tPlane < tHit && length((ro + rd * tPlane).xz) < 1.38) {
      col = mix(surfCol, col, 0.38);
    } else {
      col = surfCol;
    }
  }

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

Attribution: MIT — written for this index.

## Combines with

- [Marching Cubes](https://texelatlas.vercel.app/t/marching-cubes.md): Evaluating the decoder on a grid gives sampled distances that marching cubes turns into a triangle mesh.

## Combination ideas

- [Crack-free latent morphing via DeepSDF and Marching Tetrahedra](https://texelatlas.vercel.app/ideas/deepsdf-isosurface-marching-tetrahedra/)

## Sources

1. [primary] Jeong Joon Park, Peter Florence, Julian Straub, Richard Newcombe, Steven Lovegrove (2019) DeepSDF: Learning Continuous Signed Distance Functions for Shape Representation. arXiv preprint (cs.CV). https://arxiv.org/abs/1901.05103 (verified via arxiv on 2026-11-29)
2. [implementation] facebookresearch (2019) facebookresearch/DeepSDF. https://github.com/facebookresearch/DeepSDF License: MIT. (verified via github on 2026-11-29)

## Cite this entry

Texel. "DeepSDF (neural signed distance functions)." https://texelatlas.vercel.app/t/deepsdf-neural-sdf/ (accessed 2026-12-01).
