Manifold Mesh Booleans
A mesh boolean library that guarantees manifold output and runs in parallel, using symbolic perturbation instead of tolerance fudging. Union, difference and intersection of triangle meshes in the browser or natively.
Also known as manifold-3d
In the family Geometry, meshing & signed distance fields, mesh booleans
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | Built in | BABYLON.CSG2 (Manifold-based; await InitializeCSG2Async()) docs |
| Godot 4.7 | Built in | Add CSGShape3D nodes (CSGCombiner3D, CSGBox3D...) and set operation docs CSG meshes are combined with the bundled Manifold library. |
| Unity | None found | No built-in Manifold guaranteed-manifold boolean kernel. |
| Unreal 5.7 | Built in | Modeling Mode > Model > Boolean Tool (Union, Difference, Intersection) and GeometryScript_MeshBooleans docs |
| Blender 5.2 | Built in | Add Modifier > Generate > Boolean > Solver = Manifold docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Inputs must be manifold triangle meshes. The library finds all edge-triangle intersections using a spatial structure (a BVH or Morton-sorted hash), then decides inside/outside using a winding-number-like shadow test with symbolic perturbation: vertices are treated as if infinitesimally nudged so that degenerate coincidences, such as coplanar faces or vertices on faces, resolve consistently rather than via epsilons. New vertices are placed at the exact intersection of an edge with a face. Kept triangles from both meshes are stitched along the new intersection edges into a manifold result. The code runs in parallel and ships as a WebAssembly build for JavaScript.
When to choose it
Reach for it when
- boolean cut leaves holes or non-manifold results
- need robust union and difference of meshes in the browser
- csg for cad or 3d-print prep
- mesh intersections fail from tolerance issues
- fast parallel mesh subtraction
Choose it for CSG-style modelling on meshes (CAD in the browser, procedural parts, 3D-print prep) where robustness and manifold output matter and inputs are already manifold. Prefer SDF Modeling: CSG and Smooth Minimum when blends or smooth results are wanted, and a mesh clean-up pass or Screened Poisson Surface Reconstruction when inputs are triangle soups with self-intersections.
Field marks
- Requires manifold, closed inputs; open or self-intersecting meshes are rejected or give undefined results
- Exact coincident faces resolve via perturbation, which can leave razor-thin slivers
- Single-precision input can limit accuracy of tiny features
- Attributes such as UVs need extra bookkeeping to survive the cut
Presets
Manifold Mesh Booleans — interactive CSG Union / Difference / Intersection with highlighted 1-manifold seam curves
{
"P_BOOL_OP": 1,
"P_SEAM_GLOW": 1.15,
"P_ORBIT_AMP": 0.34,
"P_ROT_SPEED": 1
}Show GLSL (137 lines)
const float P_BOOL_OP = 1.0; // P Bool Op (0:U 1:Diff 2:Int) [0.0, 2.0, 1.0]
const float P_SEAM_GLOW = 1.15; // P Seam Curve Glow [0.0, 2.2, 0.05]
const float P_ORBIT_AMP = 0.34; // P Cutter Offset [0.05, 0.62, 0.02]
const float P_ROT_SPEED = 1.0; // P Orbit Speed [0.0, 2.5, 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;
}
// Evaluate both manifold operand SDFs A (chamfered steel cube) & B (cutter sphere + crossing cylinder)
void evalOperands(vec3 p, float spin, float orbitAmp, out float dA, out float dB) {
vec3 q = p;
q.xz = rot2(spin * 0.38) * q.xz;
q.yz = rot2(0.35) * q.yz;
dA = sdBox(q, vec3(0.56)) - 0.04;
// Dynamic manifold operand B orbiting through A
vec3 bOff = vec3(orbitAmp * cos(spin * 0.75), orbitAmp * 0.65 * sin(spin * 0.92), orbitAmp * sin(spin * 0.75));
float dSph = length(q - bOff) - 0.46;
vec3 tq = q;
tq.xy = rot2(spin * 0.5) * tq.xy;
float dTor = sdTorus(tq, vec2(0.52, 0.16));
dB = min(dSph, dTor);
}
// Exact CSG boolean combination returning vec3(distance, matID, seamProximity)
vec3 mapCSG(vec3 p, float opMode, float spin, float orbitAmp) {
float dA, dB;
evalOperands(p, spin, orbitAmp, dA, dB);
float d;
float matId;
float seam;
if (opMode < 0.5) {
// Union: A U B
d = min(dA, dB);
matId = (dA < dB) ? 1.0 : 2.0;
seam = abs(dA - dB);
} else if (opMode < 1.5) {
// Difference: A B
d = max(dA, -dB);
matId = (dA > -dB) ? 1.0 : 3.0; // interior carved face gets distinct warm-copper ID
seam = abs(dA + dB);
} else {
// Intersection: A n B
d = max(dA, dB);
matId = (dA > dB) ? 1.0 : 2.0;
seam = abs(dA - dB);
}
return vec3(d, matId, seam);
}
vec3 calcNormal(vec3 p, float opMode, float spin, float orbitAmp) {
vec2 e = vec2(0.002, 0.0);
return normalize(vec3(
mapCSG(p + e.xyy, opMode, spin, orbitAmp).x - mapCSG(p - e.xyy, opMode, spin, orbitAmp).x,
mapCSG(p + e.yxy, opMode, spin, orbitAmp).x - mapCSG(p - e.yxy, opMode, spin, orbitAmp).x,
mapCSG(p + e.yyx, opMode, spin, orbitAmp).x - mapCSG(p - e.yyx, opMode, spin, orbitAmp).x
));
}
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 opMode = floor(clamp(P_BOOL_OP + 0.5, 0.0, 2.0));
float seamGlow = clamp(P_SEAM_GLOW, 0.0, 2.5);
float orbitAmp = clamp(P_ORBIT_AMP, 0.04, 0.65);
float spin = iTime * max(P_ROT_SPEED, 0.0);
vec3 ro = vec3(0.0, 0.14, 2.52);
vec3 rd = normalize(vec3(uv, -1.52));
vec3 col = mix(vec3(0.03, 0.04, 0.068), vec3(0.09, 0.115, 0.168), smoothstep(-0.55, 0.55, uv.y));
vec2 bgG = abs(fract(uv * 10.0 - 0.5) - 0.5);
col += vec3(0.018, 0.028, 0.045) * smoothstep(0.03, 0.0, min(bgG.x, bgG.y));
float t = 0.0;
vec3 res = vec3(0.0);
bool hit = false;
for (int i = 0; i < 72; i++) {
res = mapCSG(ro + rd * t, opMode, spin, orbitAmp);
if (res.x < 0.0018) { hit = true; break; }
t += max(res.x * 0.85, 0.002);
if (t > 9.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p, opMode, spin, orbitAmp);
float matId = res.y;
float seamD = res.z;
// Distinct crisp materials for operand A (brushed slate-steel), operand B (cobalt), and carved inner B (warm brass)
vec3 alb;
if (matId < 1.5) alb = vec3(0.68, 0.72, 0.78);
else if (matId < 2.5) alb = vec3(0.18, 0.56, 0.88);
else alb = vec3(0.92, 0.52, 0.22);
// Subtle CAD grid on operand surfaces
vec3 objP = p;
objP.xz = rot2(spin * 0.38) * objP.xz;
objP.yz = rot2(0.35) * objP.yz;
vec3 gf = abs(fract(objP * 7.5 - 0.5) - 0.5);
float grid = smoothstep(0.035, 0.008, min(gf.x, min(gf.y, gf.z)));
alb *= (1.0 - 0.12 * grid);
vec3 l1 = normalize(vec3(0.62, 0.86, 0.55));
vec3 l2 = normalize(vec3(-0.75, -0.25, 0.52));
float diff1 = max(dot(n, l1), 0.0);
float diff2 = max(dot(n, l2), 0.0);
vec3 hVec = normalize(l1 - rd);
float spec = pow(max(dot(n, hVec), 0.0), 46.0) * 0.58;
float rim = pow(1.0 - max(dot(n, -rd), 0.0), 3.0) * 0.30;
col = alb * (0.24 + 0.84 * diff1 + 0.25 * diff2) + vec3(spec) + vec3(0.45, 0.75, 1.0) * rim;
// Crisp glowing exact 1-manifold CSG intersection seam curve!
float seamLine = smoothstep(0.022, 0.003, seamD);
col = mix(col, vec3(0.28, 1.0, 0.86) * (1.25 + 0.5 * seamGlow), seamLine * min(seamGlow, 1.0));
col += vec3(0.18, 0.92, 0.84) * exp(-seamD * 45.0) * 0.35 * seamGlow;
}
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: Original interactive WebGL2 fragment shader written for Texel Atlas (MIT).
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| mesh-boolean-manifold-live | Tesla T4 1920x1080 | 16.2× baseline (moderate) · 0.508 ms / 0.606 ms | opengl-timer-query · 40 frames · GPU Weight Atlas · Colab T4 sweep |
| mesh-boolean-manifold-live | NVIDIA L4 1920x1080 | 14.4× baseline (moderate) · 0.228 ms / 0.245 ms · 2.2× faster on L4 | opengl-timer-query · Cross-architecture validation |
| mesh-boolean-manifold-live | NVIDIA A100-SXM4-40GB 1920x1080 | 10.9× baseline (moderate) · 0.315 ms / 0.350 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Manifold Dual Contouring: MDC output is guaranteed manifold, so it can feed booleans.
- three-mesh-bvh: three-mesh-bvh can pick and raycast the resulting meshes in the browser.
Sources
- primaryelalish (2019). elalish/manifold. Geometry library for topological robustnessGitHub API · license Apache-2.0 · 2026-11-29