---
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"
stage: "geometry"
realtime: "realtime"
platforms: [webgpu, desktop-gpu, cuda]
year_introduced: 2019
inputs: [voxels, sdf]
outputs: [voxels, mesh]
style: "both"
dynamic: "dynamic"
cost: "cheap"
authority: "Dantas & Leal, 2019"
url: "https://texelatlas.vercel.app/t/bit-packed-3d-morphological-voxels/"
sources_verified_at: "2026-11-30"
---
# 32-Bit Word-Packed 3D Mathematical Morphology & Open-Face Indirect Emission (Dantas & Leal, 2019)

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

## Reach for it when

- 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

## 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.

Each 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.

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

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.

Prefer [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

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

## Dataflow

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

## Combines with

- [GPU-driven rendering](https://texelatlas.vercel.app/t/gpu-driven-rendering.md): Indirect draw arguments populated by the open-face emitter let the GPU render dynamically changing face counts without CPU synchronization.
- [Greedy meshing for voxel worlds](https://texelatlas.vercel.app/t/greedy-voxel-meshing.md): Coplanar exposed faces from stable regions can be merged into larger quads to reduce rasterization overhead.

## Sources

1. [primary] Daniel Oliveira Dantas, Helton Danilo Passos Leal (2019) Fast multidimensional binary image processing with OpenCL. 2019 International Conference on High Performance Computing &amp; Simulation (HPCS). https://doi.org/10.1109/hpcs48598.2019.9188210 (verified via doi.org on 2026-11-30)
2. [implementation] acher249 (2026) acher249/codevember-2026. https://github.com/acher249/codevember-2026 License: MIT. (verified via github on 2026-11-30)

## Cite this entry

Texel. "32-Bit Word-Packed 3D Mathematical Morphology & Open-Face Indirect Emission." https://texelatlas.vercel.app/t/bit-packed-3d-morphological-voxels/ (accessed 2026-12-01).
