{
 "id": "surface-nets",
 "title": "Surface Nets",
 "aliases": [],
 "domain": "geometry",
 "subdomain": "isosurface extraction",
 "stage": "geometry",
 "realtime": "interactive",
 "platforms": [
  "cpu",
  "webgl2",
  "webgpu",
  "desktop-gpu",
  "cuda",
  "unity"
 ],
 "year_introduced": 1998,
 "inputs": [
  "voxels",
  "sdf"
 ],
 "outputs": [
  "mesh"
 ],
 "style": "both",
 "dynamic": "both",
 "summary": "A dual meshing method: one vertex per surface-crossing cell, placed at the average of that cell's edge crossings, with quads across sign-changing edges. Simple, fast, smooth, with better triangle quality than marching cubes.",
 "how_it_works": "Find every cell whose corners have mixed signs. For each, compute the linearly interpolated crossing on each of its sign-changing edges and average them (the 'naive' variant) to get a single vertex. Then, for each grid edge that changes sign, connect the vertices of the four cells sharing that edge into a quad, oriented by the sign. The original paper starts from this net and relaxes it by moving vertices toward neighbour averages under a constraint that keeps each inside its cell. The result is a quad-dominant mesh with roughly regular valence and no sliver triangles, built with a simple two-pass loop and no lookup table.",
 "when_to_use": "Choose it for voxel terrain, smooth sculpting and fast chunked meshing where speed and tidy triangles matter more than sharp edges. Prefer `dual-contouring` when you need crisp corners (add normals and a QEF), `marching-cubes` when a well-known lookup-table implementation or GPU compaction path is already in hand.",
 "cost": {
  "class": "cheap",
  "notes": "Two linear passes over cells and no table lookups; usually the cheapest grid mesher in practice."
 },
 "failure_modes": [
  "Corners and creases get rounded because vertices sit at crossing averages",
  "Thin features one voxel wide can collapse or leave holes",
  "Quads may be non-planar, so triangulating along the wrong diagonal gives faceting",
  "Minor vertex shrinkage on convex regions versus the true surface"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1007/bfb0056277",
   "type": "chapter",
   "title": "Constrained elastic surface nets: Generating smooth surfaces from binary segmented data",
   "authors": [
    "Sarah F. F. Gibson"
   ],
   "year": 1998,
   "venue": "Lecture Notes in Computer Science",
   "url": "https://doi.org/10.1007/bfb0056277",
   "ids": {
    "doi": "10.1007/bfb0056277"
   },
   "license": null,
   "extra": {
    "csl_type": "book-chapter"
   },
   "provenance": {
    "title": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1007/bfb0056277",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1007/bfb0056277",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1007/bfb0056277",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1007/bfb0056277",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "crossref",
     "endpoint": "https://api.crossref.org/works/10.1007/bfb0056277",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": 1,
   "__bib": "gibson1998constrained"
  },
  {
   "role": "tutorial",
   "key": "url:https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2",
   "type": "tutorial",
   "title": "Smooth Voxel Terrain (Part 2)",
   "authors": [
    "Mikola Lysenko"
   ],
   "year": null,
   "venue": "0fps.net",
   "url": "https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2",
   "ids": {},
   "license": null,
   "extra": {
    "http_status": 200,
    "live": true,
    "archive": {
     "url": "http://web.archive.org/web/20261003181456/https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2/",
     "timestamp": "20261003181456"
    },
    "page_title": "Smooth Voxel Terrain (Part 2)",
    "host": "0fps.net",
    "title_confirmed_by_page": true,
    "title_unconfirmed": false
   },
   "provenance": {
    "title": {
     "authority": "http",
     "endpoint": "GET https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2 → 200",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "http",
     "endpoint": "GET https://0fps.net/2012/07/12/smooth-voxel-terrain-part-2 → 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://0fps.net/2012/07/12/smooth-voxel-terrain-part-2 → 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": "lysenkosmooth"
  },
  {
   "role": "implementation",
   "key": "gh:mikolalysenko/isosurface",
   "type": "code",
   "title": "mikolalysenko/isosurface",
   "description": "Isosurface polygonizer algorithms",
   "authors": [
    "mikolalysenko"
   ],
   "year": 2013,
   "venue": "GitHub",
   "url": "https://github.com/mikolalysenko/isosurface",
   "ids": {
    "repo": "mikolalysenko/isosurface"
   },
   "license": "MIT",
   "extra": {
    "stars": 195,
    "stars_checked": "2026-11-29",
    "archived": false,
    "fork": false,
    "pushed_at": "2014-04-29T18:52:01Z",
    "language": "JavaScript",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mikolalysenko/isosurface",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mikolalysenko/isosurface",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mikolalysenko/isosurface",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mikolalysenko/isosurface",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mikolalysenko/isosurface",
     "checked_at": "2026-11-29T15:51:27.588Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/mikolalysenko/isosurface",
     "checked_at": "2026-11-29T15:51:27.588Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-29T15:51:27.588Z",
   "title_sim": null,
   "__bib": "mikolalysenko2013mikolalysenkob"
  }
 ],
 "presets": [
  {
   "id": "surface-nets-specimen",
   "title": "Toy 2D surface nets: mean-of-crossings cell vertices joined into a contour",
   "runtime": "glsl-fragment",
   "params": {
    "CELLS": 9
   },
   "code": "// Toy 2D surface nets: one vertex per mixed cell at the mean of its edge crossings, joined across shared crossing edges.\nconst float CELLS = 9.0;\nfloat field(vec2 p) {\n    vec2 q = abs(p - 0.5) - vec2(0.27, 0.19 + 0.04 * sin(iTime));\n    return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - 0.07;\n}\nfloat segd(vec2 p, vec2 a, vec2 b) {\n    vec2 pa = p - a, ba = b - a;\n    return length(pa - ba * clamp(dot(pa, ba) / max(dot(ba, ba), 1e-6), 0.0, 1.0));\n}\n// vertex of cell (i,j); w = 0 when the cell is not mixed\nvec3 vtx(vec2 ij, float cs) {\n    vec2 c0 = ij * cs;\n    vec2 P[4]; float F[4];\n    P[0] = c0; P[1] = c0 + vec2(cs, 0); P[2] = c0 + cs; P[3] = c0 + vec2(0, cs);\n    for (int i = 0; i < 4; i++) F[i] = field(P[i]);\n    vec2 s = vec2(0); float n = 0.0;\n    for (int i = 0; i < 4; i++) {\n        int j = (i + 1) % 4;\n        if ((F[i] > 0.0) != (F[j] > 0.0)) { s += mix(P[i], P[j], F[i] / (F[i] - F[j])); n += 1.0; }\n    }\n    return n > 0.0 ? vec3(s / n, 1.0) : vec3(0.0);\n}\nvoid mainImage(out vec4 fragColor, in vec2 fragCoord) {\n    vec2 uv = fragCoord / iResolution.xy;\n    float cs = 1.0 / CELLS;\n    vec2 cell = floor(uv / cs);\n    float dl = 1e9, dv = 1e9;\n    for (int j = -1; j <= 1; j++) for (int i = -1; i <= 1; i++) {\n        vec2 ij = cell + vec2(i, j);\n        vec3 v = vtx(ij, cs);\n        if (v.z == 0.0) continue;\n        dv = min(dv, length(uv - v.xy));\n        vec3 vr = vtx(ij + vec2(1, 0), cs), vu = vtx(ij + vec2(0, 1), cs);\n        vec2 e1 = (ij + vec2(1, 0)) * cs, e2 = e1 + vec2(0, cs);\n        if (vr.z > 0.0 && (field(e1) > 0.0) != (field(e2) > 0.0)) dl = min(dl, segd(uv, v.xy, vr.xy));\n        vec2 f1 = (ij + vec2(0, 1)) * cs, f2 = f1 + vec2(cs, 0);\n        if (vu.z > 0.0 && (field(f1) > 0.0) != (field(f2) > 0.0)) dl = min(dl, segd(uv, v.xy, vu.xy));\n    }\n    float f = field(uv);\n    vec3 col = vec3(0.07, 0.08, 0.11) + (f < 0.0 ? vec3(0.06, 0.1, 0.16) : vec3(0.0));\n    vec2 g = abs(fract(uv / cs) - 0.5);\n    col = mix(col, vec3(0.22, 0.24, 0.32), smoothstep(0.02, 0.0, 0.5 - max(g.x, g.y)));\n    col = mix(col, vec3(0.95, 0.75, 0.3), smoothstep(0.005, 0.003, dl));\n    col = mix(col, vec3(0.35, 0.9, 1.0), smoothstep(0.012, 0.009, dv));\n    fragColor = vec4(pow(col, vec3(0.8)), 1.0);\n}\n",
   "basis": "original",
   "license_note": "written for this index",
   "execution_fidelity": "conceptual-diagram",
   "proof": {
    "kind": "rendered",
    "label": "rendered 2026-11-29",
    "ok": true,
    "proof": {
     "ok": true,
     "technique": "surface-nets",
     "runtime": "glsl-fragment",
     "checked_at": "2026-11-29T15:51:50.471Z",
     "renderer": "Chromium 145.0.7632.6 headless, WebGL2 via ANGLE/SwiftShader, 512×512, iTime=1.5",
     "stats": {
      "mean": 0.1994,
      "std": 0.1092,
      "unique_colors": 58
     },
     "image": "/specimens/surface-nets-specimen.webp",
     "reason": null
    }
   }
  }
 ],
 "related": [
  "marching-cubes",
  "dual-contouring",
  "manifold-dual-contouring"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "taubin-smoothing",
   "why": "Optional post-relaxation without shrinkage for binary-segmentation input."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-29T15:51:27.588Z",
  "draft": "data/drafts/geometry/surface-nets.json"
 },
 "solves": [
  "marching cubes gives ugly thin triangles",
  "smooth voxel terrain meshing at speed",
  "chunked meshing for sculpting tools",
  "need tidy quads from a scalar field",
  "simple fast isosurface extraction"
 ],
 "authority": "Gibson, 1998",
 "url": "https://texelatlas.vercel.app/t/surface-nets/",
 "execution_fidelity": "conceptual-diagram",
 "fidelity_label": "Visual Diagram",
 "benchmark_eligible": false,
 "gpu_weight": {
  "weight_x": 19.62,
  "tier": "moderate",
  "p50_ms": 0.6454,
  "p95_ms": 0.7286,
  "baseline_p50_ms": 0.0329,
  "gpu": "Tesla T4/PCIe/SSE2",
  "resolution": "1920x1080",
  "method": "opengl-timer-query",
  "frames": 40,
  "preset_id": "surface-nets-specimen",
  "execution_fidelity": "conceptual-diagram",
  "fidelity_label": "Visual Diagram",
  "benchmark_eligible": false,
  "generated_at": "2026-11-30T21:07:47Z",
  "l4": {
   "weight_x": 18.86,
   "tier": "moderate",
   "p50_ms": 0.2999,
   "p95_ms": 0.3229,
   "speedup_x": 2.15,
   "gpu": "NVIDIA L4/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0159
  },
  "a100": {
   "weight_x": 12.47,
   "tier": "moderate",
   "p50_ms": 0.3591,
   "p95_ms": 0.3859,
   "speedup_x": 1.8,
   "gpu": "NVIDIA A100-SXM4-40GB/PCIe/SSE2",
   "resolution": "1920x1080",
   "baseline_p50_ms": 0.0288
  }
 }
}