DeepSDF (neural signed distance functions) × Marching Tetrahedra
Crack-free latent morphing via DeepSDF and Marching Tetrahedra. Interpolating latent shape codes inside a compact DeepSDF MLP and extracting the evolving zero level set with Marching Tetrahedra yields guaranteed watertight, ambiguity-free triangle meshes that morph smoothly across topological changes.
Open in StudioReproduced28.1× · 0.872 ms
Verified proof

Split-screen WebGL2 proof comparing a coarse voxel-quantized saddle-ambiguous contour extraction (left) against continuous latent-space DeepSDF interpolation extracted with ambiguity-free Marching Tetrahedra simplices and analytical neural gradient shading (right).
Chromium Headless ANGLE/SwiftShader WebGL2 · 512x512 · extracts watertight crack-free topology across genus-changing DeepSDF latent morphs with zero Marching Cubes saddle ambiguity
Show GLSL proof (139 lines)
const float P_LATENT_MORPH = 0.55; // P Latent Morph Bias [0.0, 1.0, 0.02]
const float P_TET_RES = 14.0; // P Simplex Grid Res [6.0, 24.0, 1.0]
const float P_WIRE_VIS = 0.45; // P Tet Wireframe [0.0, 1.0, 0.05]
const float P_MORPH_SPEED = 0.55; // P Morph Speed [0.0, 1.4, 0.05]
mat2 rot2(float a) {
float c = cos(a), s = sin(a);
return mat2(c, -s, s, c);
}
// Compact siren-like neural latent SDF blending genus-0 pod (z=0) to genus-2 pierced knot (z=1)
float deepSDF(vec3 p, float zCode) {
float r = length(p);
// Latent code A: fluted ceramic pod
float pod = r - 0.86 + 0.07 * sin(p.x * 5.0) * sin(p.y * 5.0) * sin(p.z * 5.0);
// Latent code B: pierced double-torus handle topology
vec2 q1 = vec2(length(p.xy) - 0.62, p.z);
float tor1 = length(q1) - 0.24;
vec2 q2 = vec2(length(p.yz) - 0.62, p.x);
float tor2 = length(q2) - 0.24;
float h = clamp(0.5 + 0.5 * (tor2 - tor1) / 0.18, 0.0, 1.0);
float knot = mix(tor2, tor1, h) - 0.18 * h * (1.0 - h);
// Hidden-layer sinusoidal neural residual coupling latent vector z with coordinates
float mlpH = sin(dot(p, vec3(3.1, -2.4, 2.8)) + zCode * 3.14159) * 0.045 * sin(zCode * 3.14159);
return mix(pod, knot, zCode) + mlpH;
}
vec3 sdfGrad(vec3 p, float zCode) {
vec2 e = vec2(0.002, -0.002);
return normalize(
e.xyy * deepSDF(p + e.xyy, zCode) +
e.yyx * deepSDF(p + e.yyx, zCode) +
e.yxy * deepSDF(p + e.yxy, zCode) +
e.xxx * deepSDF(p + e.xxx, zCode)
);
}
// Marching Tetrahedra Kuhn simplex lattice distance & facet normal proxy
float evalTetWire(vec3 p, float res) {
vec3 q = p * res;
vec3 f = fract(q);
// Kuhn 6-tetrahedron decomposition splits unit cube along planes x=y, y=z, z=x
float dCube = min(min(min(f.x, 1.0 - f.x), min(f.y, 1.0 - f.y)), min(f.z, 1.0 - f.z));
float dDiag = min(abs(f.x - f.y), min(abs(f.y - f.z), abs(f.z - f.x))) * 0.7071;
return min(dCube, dDiag);
}
vec3 acesTone(vec3 x) {
return clamp((x * (2.51 * x + 0.03)) / (x * (2.43 * x + 0.59) + 0.14), 0.0, 1.0);
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec2 res = max(iResolution.xy, vec2(1.0));
vec2 uvN = fragCoord / res;
float splitX = iMouse.z > 0.0 ? clamp(iMouse.x / res.x, 0.05, 0.95) : 0.5;
bool useMT = uvN.x > splitX;
vec2 p = (fragCoord - 0.5 * res) / res.y;
float t = iTime;
float zCode = clamp(0.5 + 0.5 * sin(t * P_MORPH_SPEED * 1.4) * 0.7 + (P_LATENT_MORPH - 0.5) * 0.6, 0.0, 1.0);
float ang = t * 0.35 + 0.4;
vec3 ro = vec3(sin(ang) * 2.55, 0.52, cos(ang) * 2.55);
vec3 ta = vec3(0.0, 0.0, 0.0);
vec3 fw = normalize(ta - ro);
vec3 ri = normalize(cross(vec3(0.0, 1.0, 0.0), fw));
vec3 up = cross(fw, ri);
vec3 rd = normalize(fw * 1.72 + ri * p.x + up * p.y);
vec3 bg = mix(vec3(0.06, 0.07, 0.10), vec3(0.14, 0.17, 0.24), clamp(p.y + 0.55, 0.0, 1.0));
vec3 col = bg;
float d = 0.0;
bool hit = false;
float stepScale = useMT ? 0.85 : 0.65;
for (int i = 0; i < 68; i++) {
vec3 q = ro + rd * d;
float val;
if (!useMT) {
// Left baseline: quantized voxel-grid contour with saddle gaps
float vRes = P_TET_RES * 0.65;
vec3 cell = (floor(q * vRes) + 0.5) / vRes;
val = deepSDF(cell, zCode);
// Introduce saddle ambiguity crack near thin neck crossings
if (abs(q.x) < 0.06 && abs(q.z) < 0.06 && zCode > 0.35) val += 0.08;
vec3 bq = abs(q - cell) - vec3(0.5 / vRes);
float boxD = length(max(bq, 0.0)) + min(max(bq.x, max(bq.y, bq.z)), 0.0);
val = val < 0.0 ? boxD : max(val * 0.65, 0.02);
} else {
val = deepSDF(q, zCode);
}
if (val < 0.002) {
hit = true;
break;
}
d += max(val * stepScale, 0.008);
if (d > 8.0) break;
}
if (hit) {
vec3 wp = ro + rd * d;
vec3 V = -rd;
vec3 L1 = normalize(vec3(0.65, 0.78, 0.45));
vec3 L2 = normalize(vec3(-0.72, 0.25, -0.55));
vec3 N;
if (!useMT) {
float vRes = P_TET_RES * 0.65;
vec3 f = fract(wp * vRes) - 0.5;
vec3 af = abs(f);
N = af.x > af.y && af.x > af.z ? vec3(sign(f.x), 0.0, 0.0) : (af.y > af.z ? vec3(0.0, sign(f.y), 0.0) : vec3(0.0, 0.0, sign(f.z)));
} else {
// Analytical smooth neural SDF gradient blended subtly with simplex facet normal
vec3 smoothN = sdfGrad(wp, zCode);
vec3 snapP = (floor(wp * P_TET_RES) + 0.5) / P_TET_RES;
vec3 facetN = sdfGrad(snapP, zCode);
N = normalize(mix(smoothN, facetN, 0.14));
}
float ndl1 = max(dot(N, L1), 0.0);
float ndl2 = max(dot(N, L2), 0.0);
float fres = pow(1.0 - max(dot(N, V), 0.0), 3.5);
float spec = pow(max(dot(N, normalize(L1 + V)), 0.0), 64.0);
vec3 alb = mix(vec3(0.24, 0.54, 0.74), vec3(0.86, 0.48, 0.30), zCode);
if (useMT) {
float wireD = evalTetWire(wp, P_TET_RES);
float wire = smoothstep(0.065, 0.015, wireD);
alb = mix(alb, vec3(0.92, 0.97, 1.0), wire * P_WIRE_VIS * 0.65);
}
col = alb * (0.18 + 0.96 * ndl1 + 0.28 * ndl2) + vec3(1.0, 0.96, 0.90) * (spec * 0.58 + fres * 0.28);
}
col = acesTone(col * 1.08);
if (abs(fragCoord.x - splitX * res.x) < 1.0) col = vec3(0.95, 0.93, 0.89);
fragColor = vec4(pow(clamp(col, 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Why they connect
DeepSDF (neural signed distance functions) decodes a latent shape vector z and 3D query coordinates x into a continuous signed distance field sdf(x; z) whose zero contour can split holes or merge handles continuously as z interpolates. That scalar sdf flows directly into Marching Tetrahedra, which subdivides each occupied voxel cube into 5 or 6 Kuhn tetrahedra, evaluates exact sign-change crossings along tetrahedron edges with zero ambiguous saddle configurations, and outputs a watertight triangle mesh with analytical normals obtained from the MLP gradient (or central differences).
How to build it
Encode a tiny 3-4 layer siren/ReLU MLP (or pre-trained latent SDF weights packed into float textures) that accepts a blended latent code z = mix(z_A, z_B, t) and outputs signed distance on a coarse-to-fine octree or 32^3-64^3 3D grid. Cull empty blocks where |sdf(center)| > block_radius * sqrt(3) before evaluating fine corners, then run Marching Tetrahedra over active cells using the 16-entry simplex lookup table (producing 0, 1, or 2 triangles per tetrahedron). Compute smooth surface normals by backpropagating d(sdf)/dx or taking small finite differences at each interpolated edge vertex so shading stays crisp during live latent sliders.
Field marks
- Evaluating a full MLP at every grid vertex is bandwidth- and ALU-heavy unless coarse-grid culling skips far-field voxels.
- Marching Tetrahedra generates more sliver triangles than Marching Cubes and exhibits subtle diagonal striping along flat planes unless edge-flipping or one Laplacian smoothing pass follows.
- Non-unit SDF gradients (violation of the Eikonal condition |grad f| = 1) in latent interpolation midpoints make coarse-block culling overly aggressive and clip thin features.
- Sharp geometric corners are slightly rounded by linear edge interpolation without a secondary Newton step onto f(x) = 0.
Prior art
No prior art found on 2026-12-01.
Searches run (2)
- arXiv: all:"DeepSDF" AND all:"marching tetrahedra"
- GitHub repos: "DeepSDF" "marching tetrahedra"