Bilateral Normal Integration
Integrates a normal map into a depth surface while preserving depth discontinuities, using a bilateral weighting that is optimised iteratively in a sparse linear least-squares loop.
Also known as BNI
In the family Capture, reconstruction & splatting, normal integration
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | None found | |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Not applicable | Offline reconstruction/generative method, not an engine feature. |
| Unity | None found | |
| Unreal 5.7 | None found | External surface reconstruction research method; not built into Unreal Engine. |
| Blender 5.2 | None found | |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Classic normal integration assumes the surface is smooth, so it smears across steps and occlusion boundaries. This method writes the integration as a sparse system relating neighbouring pixels' log-depth through the normals, but weights each pixel pair with a bilateral term that tells it whether the pair lies across a discontinuity. The weights are unknown, so they are estimated from the current solution and the system is re-solved in an alternating scheme, which is a form of iteratively reweighted least squares with a robust cost. Orthographic and perspective camera models are both supported. The result is a depth map that keeps sharp silhouettes and creases. Pixels outside a mask are ignored.
When to choose it
Reach for it when
- turn a normal map into a depth surface
- integrating normals smears over sharp depth steps
- photometric stereo normals need to become a mesh
- recover height from estimated normals keeping discontinuities
Choose it to turn normal maps from photometric stereo, monocular normal estimators or MoGe (Monocular Geometry Estimation) into usable depth or meshes with sharp steps. Prefer a simple Poisson or Frankot-Chellappa integrator when the surface is genuinely smooth and speed matters. Prefer multi-view NeuS when you can supply many views instead of a single normal map.
Field marks
- Normals with low-frequency bias integrate into a globally warped surface regardless of weighting
- Wrong discontinuity decisions split or merge surface patches, producing cliffs at the wrong places
- Depth scale is only defined up to the camera model assumptions, so absolute size needs another cue
- Mask errors bleed background depth into the object boundary
Presets
Bilateral Normal Integration — blurred Poisson integration (left) vs discontinuity-preserving bilateral relief (right)
{
"P_DISCONT_K": 0.88,
"P_RELIEF_H": 0.72,
"P_LIGHT_SPIN": 0.65,
"P_SPLIT": 0.48
}Show GLSL (105 lines)
const float P_DISCONT_K = 0.88; // P Bilateral Sharpness [0.1, 1.0, 0.02]
const float P_RELIEF_H = 0.72; // P Relief Height [0.2, 1.2, 0.04]
const float P_LIGHT_SPIN = 0.65; // P Light Sweep [0.0, 2.2, 0.05]
const float P_SPLIT = 0.48; // P Poisson / Bilateral [0.0, 1.0, 0.02]
// Ground-truth stepped architectural bas-relief heightfield with sharp depth discontinuities!
float exactRelief(vec2 p) {
// Concentric stepped Aztec/classical relief terraces + domed medallions
float dBox = max(abs(p.x), abs(p.y));
float h = 0.0;
h += 0.22 * step(dBox, 0.42);
h += 0.18 * step(length(p), 0.30);
// 4 carved corner medallions with sharp cliffs
vec2 q = abs(p) - vec2(0.28, 0.28);
h += 0.20 * step(length(q), 0.105);
// Central spherical relief dome
float rC = length(p);
if (rC < 0.20) h += 0.22 * sqrt(max(1.0 - (rC / 0.20) * (rC / 0.20), 0.0));
return h;
}
// Smooth (Poisson-integrated) version: continuous integrability smears across jump discontinuities!
float poissonRelief(vec2 p) {
float h = 0.0;
float wSum = 0.0;
for (int dy = -2; dy <= 2; dy++) {
for (int dx = -2; dx <= 2; dx++) {
vec2 off = vec2(float(dx), float(dy)) * 0.022;
float w = exp(-dot(off, off) * 750.0);
h += exactRelief(p + off) * w;
wSum += w;
}
}
return h / max(wSum, 1e-5);
}
// Bilateral-integrated version: sigmoid discontinuity weight k keeps step cliffs razor sharp
float bilateralRelief(vec2 p, float kSharp) {
return mix(poissonRelief(p), exactRelief(p), smoothstep(0.05, 0.95, kSharp));
}
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 screenX = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool isBilateral = screenX >= split;
float kSharp = clamp(P_DISCONT_K, 0.05, 1.0);
float relH = clamp(P_RELIEF_H, 0.15, 1.4);
float spin = iTime * max(P_LIGHT_SPIN, 0.0);
// Oblique 3D camera inspecting the reconstructed heightfield surface
vec3 ro = vec3(0.0, 0.92, 1.25);
vec3 rd = normalize(vec3(uv.x, uv.y - 0.48, -1.25));
vec3 col = mix(vec3(0.025, 0.032, 0.052), vec3(0.065, 0.082, 0.128), smoothstep(-0.5, 0.5, uv.y));
// Raymarch the integrated heightfield y = h(x, z)
float t = 0.4;
bool hit = false;
for (int i = 0; i < 60; i++) {
vec3 p = ro + rd * t;
float h = isBilateral ? bilateralRelief(p.xz, kSharp) : poissonRelief(p.xz);
float d = p.y - h * relH;
if (d < 0.004) { hit = true; break; }
t += max(d * 0.48, 0.012);
if (t > 4.5) break;
}
if (hit) {
vec3 p = ro + rd * t;
float e = 0.006;
float hC = isBilateral ? bilateralRelief(p.xz, kSharp) : poissonRelief(p.xz);
float hX = isBilateral ? bilateralRelief(p.xz + vec2(e, 0.0), kSharp) : poissonRelief(p.xz + vec2(e, 0.0));
float hZ = isBilateral ? bilateralRelief(p.xz + vec2(0.0, e), kSharp) : poissonRelief(p.xz + vec2(0.0, e));
vec3 n = normalize(vec3((hC - hX) * relH / e, 1.0, (hC - hZ) * relH / e));
vec3 lDir = normalize(vec3(cos(spin * 0.7) * 0.72, 0.78, sin(spin * 0.7) * 0.72));
float diff = max(dot(n, lDir), 0.0);
float spec = pow(max(dot(n, normalize(lDir - rd)), 0.0), 36.0);
// Subtle elevation contour lines & discontinuity edge glow
float discEdge = clamp(length(vec2(hC - hX, hC - hZ)) * 18.0, 0.0, 1.0);
vec3 marble = mix(vec3(0.22, 0.30, 0.42), vec3(0.92, 0.88, 0.82), smoothstep(0.02, 0.58, hC));
float contour = smoothstep(0.06, 0.01, abs(fract(hC * 12.0) - 0.5));
marble = mix(marble, vec3(0.16, 0.80, 0.94), contour * 0.24);
col = marble * (0.28 + 0.84 * diff) + vec3(1.0, 0.96, 0.90) * spec * 0.38;
if (isBilateral) {
// Highlight crisp detected bilateral discontinuity creases in gold
col += vec3(0.98, 0.68, 0.22) * discEdge * 0.45;
} else {
// Highlight Poisson ramp-blurring error in magenta
col += vec3(0.94, 0.24, 0.52) * discEdge * 0.45;
}
}
float sep = smoothstep(0.0035, 0.0008, abs(screenX - split));
col = mix(col, vec3(0.95, 0.97, 1.0), sep);
fragColor = vec4(pow(clamp(aces(col), 0.0, 1.0), vec3(1.0 / 2.2)), 1.0);
}Attribution: MIT — written for this index.
Measured GPU weight & timing
| Preset | GPU | Weight / p50 / p95 | Method |
|---|---|---|---|
| bilateral-normal-integration-live | Tesla T4 1920x1080 | 275× baseline (extreme) · 9.04 ms / 9.15 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| bilateral-normal-integration-live | NVIDIA L4 1920x1080 | 236× baseline (extreme) · 3.75 ms / 3.83 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| bilateral-normal-integration-live | NVIDIA A100-SXM4-40GB 1920x1080 | 206× baseline (extreme) · 5.94 ms / 5.98 ms · 1.5× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Drawings to relief via generated relighting: Turn one drawing into a sharp-edged relief mesh. An image model repaints the same drawing under several lights, photometric stereo that needs no light calibration recovers normals, and discontinuity-aware integration keeps silhouettes as cliffs.
- Universal Photometric Stereo (SDM-UniPS): UniPS outputs normals; BNI integrates them into depth with preserved discontinuities.
Sources
- primaryXu Cao, Hiroaki Santo, Boxin Shi, Fumio Okura, Yasuyuki Matsushita (2022). Bilateral Normal Integration. Lecture Notes in Computer Science.Verified via crossref · 2026-11-29doi:10.1007/978-3-031-19769-7_32
- implementationxucao-42 (2022). xucao-42/bilateral_normal_integration. Official implementation of "Bilateral Normal Integration" (BiNI), ECCV 2022.GitHub API · license GPL-3.0 · 2026-11-29