{
 "id": "bit-packed-3d-morphological-voxels",
 "title": "32-Bit Word-Packed 3D Mathematical Morphology & Open-Face Indirect Emission",
 "aliases": [
  "bit-packed 3D morphology",
  "word-packed voxel erosion",
  "bitmask voxel sculpting"
 ],
 "domain": "geometry",
 "subdomain": "voxel morphology & meshing",
 "stage": "geometry",
 "realtime": "realtime",
 "platforms": [
  "webgpu",
  "desktop-gpu",
  "cuda"
 ],
 "year_introduced": 2019,
 "inputs": [
  "voxels",
  "sdf"
 ],
 "outputs": [
  "voxels",
  "mesh"
 ],
 "style": "both",
 "dynamic": "dynamic",
 "summary": "Stores a binary 3D voxel volume at 1 bit per cell inside 32-bit GPU words, running bitwise erosion and dilation in compute shaders and emitting only exposed boundary faces via indirect draw buffers.",
 "how_it_works": "Binary 3D mathematical morphology—erosion, dilation, opening, and closing—normally stalls on memory bandwidth when stored at one byte or float per voxel. Packing **32 consecutive cells along X into a single `uint32`** cuts storage and memory traffic by 32×, allowing grids of `256³` to `472³` voxels to reside comfortably in a few megabytes of GPU storage buffers.\n\nEach compute pass reads a destination word together with its neighbor words across the structuring element's footprint (such as a 6-connected cross or spherical brush). Along the packed axis, shifted neighbor bits are assembled in registers via bitwise shifts and masks (`(curr >> 1) | (next << 31)`), so **erosion** reduces to bitwise `AND` over the neighborhood while **dilation** reduces to bitwise `OR`—updating 32 voxels per word operation.\n\nFor rendering without full-volume ray marching or CPU readbacks, a second compute pass computes the **6 open-face bitmasks** per word (`solid & ~neighbor_solid`) along `±X, ±Y, ±Z`. Threads iterate over set bits with count-trailing-zeros (`ctz`) and atomically append exposed quad coordinates to a flat face buffer, writing the exact vertex count into an indirect draw argument buffer for a single instanced GPU draw call.",
 "when_to_use": "Choose it when you need interactive sculpting, real-time morphological erosion/growth, or destruction on high-resolution dense binary voxel grids on compute-capable GPUs.\n\nPrefer [greedy-voxel-meshing](greedy-voxel-meshing) when chunks are mostly static and minimizing triangle count for rasterization matters more than per-frame rebuild speed. Prefer [nanovdb](nanovdb) when the volume is huge and sparse or needs floating-point densities rather than binary occupancy. Prefer [marching-cubes](marching-cubes) when you want smooth isosurfaces instead of crisp cubical voxel faces.",
 "cost": {
  "class": "cheap",
  "notes": "32× bit-packing keeps morphological compute passes and open-face emission under 1 ms for 128³–256³ grids and a few milliseconds up to 472³ on desktop WebGPU, though dense face counts still depend on surface complexity."
 },
 "failure_modes": [
  "Fixed dense 3D allocation scales cubically with resolution, limiting maximum world extent compared to sparse trees",
  "Repeated erosion followed by dilation (morphological opening) permanently rounds corners and deletes thin tendrils smaller than the structuring element",
  "Worst-case porous or checkerboard volumes can overflow fixed-capacity indirect face buffers if no budget cap or multi-pass compaction is enforced",
  "Binary occupancy stores no sub-voxel surface normals, requiring screen-space shading, AO, or dual-grid smoothing to avoid stair-stepped lighting"
 ],
 "sources": [
  {
   "role": "primary",
   "key": "doi:10.1109/hpcs48598.2019.9188210",
   "type": "paper",
   "title": "Fast multidimensional binary image processing with OpenCL",
   "authors": [
    "Daniel Oliveira Dantas",
    "Helton Danilo Passos Leal"
   ],
   "year": 2019,
   "venue": "2019 International Conference on High Performance Computing &amp; Simulation (HPCS)",
   "url": "https://doi.org/10.1109/hpcs48598.2019.9188210",
   "ids": {
    "doi": "10.1109/hpcs48598.2019.9188210"
   },
   "license": null,
   "extra": {
    "csl_type": "proceedings-article"
   },
   "provenance": {
    "title": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1109/hpcs48598.2019.9188210 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1109/hpcs48598.2019.9188210 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1109/hpcs48598.2019.9188210 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1109/hpcs48598.2019.9188210 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "doi.org",
     "endpoint": "https://doi.org/10.1109/hpcs48598.2019.9188210 (CSL-JSON)",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": 1,
   "__bib": "dantas2019fast"
  },
  {
   "role": "implementation",
   "key": "gh:acher249/codevember-2026",
   "type": "code",
   "title": "acher249/codevember-2026",
   "description": "#codevember ",
   "authors": [
    "acher249"
   ],
   "year": 2026,
   "venue": "GitHub",
   "url": "https://github.com/acher249/codevember-2026",
   "ids": {
    "repo": "acher249/codevember-2026"
   },
   "license": "MIT",
   "extra": {
    "stars": 133,
    "stars_checked": "2026-11-30",
    "archived": false,
    "fork": false,
    "pushed_at": "2026-11-29T23:19:53Z",
    "language": "TypeScript",
    "homepage": null,
    "license_name": "MIT License"
   },
   "provenance": {
    "title": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/acher249/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "authors": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/acher249/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "year": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/acher249/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "venue": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/acher249/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "url": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/acher249/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    },
    "license": {
     "authority": "github",
     "endpoint": "https://api.github.com/repos/acher249/codevember-2026",
     "checked_at": "2026-11-30T17:59:51.239Z"
    }
   },
   "status": "verified",
   "checked_at": "2026-11-30T17:59:51.239Z",
   "title_sim": null,
   "__bib": "acher2026acher249"
  }
 ],
 "presets": [],
 "related": [
  "greedy-voxel-meshing",
  "gpu-driven-rendering",
  "nanovdb",
  "voxel-grid-dda-traversal"
 ],
 "extends": [],
 "supersedes": [],
 "combines_with": [
  {
   "id": "gpu-driven-rendering",
   "why": "Indirect draw arguments populated by the open-face emitter let the GPU render dynamically changing face counts without CPU synchronization."
  },
  {
   "id": "greedy-voxel-meshing",
   "why": "Coplanar exposed faces from stable regions can be merged into larger quads to reduce rasterization overhead."
  }
 ],
 "provenance": {
  "prose": "original text written for this index (research draft, editorially reviewed)",
  "sources_verified_at": "2026-11-30T17:59:51.239Z",
  "draft": "data/drafts/geometry/bit-packed-3d-morphological-voxels.json"
 },
 "solves": [
  "3d voxel erosion or dilation uses too much vram and bandwidth",
  "need fast gpu morphological opening closing or smoothing on voxel masks",
  "pack 64 binary voxels per word for single-instruction neighbor stencils",
  "sculpt and clean up noisy voxel occupancy grids at interactive rates",
  "compute bitwise 3d flood fill and bevel masks in compute shaders"
 ],
 "authority": "Dantas & Leal, 2019",
 "url": "https://texelatlas.vercel.app/t/bit-packed-3d-morphological-voxels/",
 "execution_fidelity": "none",
 "fidelity_label": "No Live Specimen",
 "benchmark_eligible": false
}