High-to-low-poly normal map baking
Captures the surface detail of a dense mesh into a tangent-space normal map on a simplified one by casting from low-poly surface points to the high-poly surface, so cheap geometry shades like the sculpt.
Also known as normal baking, detail transfer
In the family Materials, BRDFs & texturing, asset pipeline
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 | None found | |
| Unity | None found | |
| Unreal 5.7 | Built in | Modeling Mode > Bake > Bake Textures (or GeometryScript_Bake normal map baking) docs |
| Blender 5.2 | Built in | Render Properties > Bake (Cycles) > Bake Type = Normal, with Selected to Active docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Both meshes share a pose and the low-poly mesh needs a unique, non-overlapping UV layout. For every texel of the low-poly UV atlas, find its 3D point and interpolated normal, then find the matching point on the high-poly surface. Ray casting along or against the normal out to a cage distance is the common method; a GPU version rasterises the high-poly mesh in the low-poly's UV space and compares attributes. The high-poly normal at the hit is transformed into the low-poly tangent frame and packed as rgb = n*0.5+0.5. The tangent frame used for baking has to be the one the runtime uses, so synchronised tangent generation (Normal mapping with MikkTSpace) is mandatory. A cage, an inflated copy of the low mesh, bounds the ray start and avoids hits on the wrong layer. The same pass can emit ambient occlusion, curvature, position and thickness maps from the same hits.
When to choose it
Reach for it when
- want detail of a sculpt on a low poly mesh
- baked normal map looks skewed or wavy
- need to transfer high poly detail to game asset
- dark seams appear along uv edges after baking
- setting up a cage for bake rays
Choose it for any game character, prop or hard-surface asset where the visible detail is sculpted or modelled at high density. Prefer displacement or Nanite virtualized geometry when silhouette detail is needed. Prefer Parallax occlusion mapping for depth parallax on the baked result. Use Quadric Error Metric Simplification or Instant Field-Aligned Meshes to produce the low-poly target, and xatlas for UVs. For purely procedural detail, skip baking and use Surface gradient based bump mapping framework in the shader.
Field marks
- Skewed or wavy lines when the cage or ray direction is mismatched to the low-poly normals
- Floating geometry gets baked onto the wrong surface when rays hit the nearest layer
- Seam breaks at UV islands with different tangent handedness, and mirrored UVs bake incorrectly
- Hard edges on the low-poly need split normals or UV islands, otherwise gradients smear across the edge
- Baked in a different tangent basis from the one used at runtime gives lighting that looks inverted
- Texel padding too small causes dark halos when mips are generated
Presets
Normal Map Baking — low-poly mesh & tangent-space normal map (left) vs high-to-low baked shading (right)
{
"P_SCULPT_DEPTH": 0.85,
"P_RIVET_FREQ": 6,
"P_SPIN_SPEED": 0.42,
"P_SPLIT": 0.48
}Show GLSL (141 lines)
const float P_SCULPT_DEPTH = 0.85; // P Sculpt Relief [0.2, 1.6, 0.05]
const float P_RIVET_FREQ = 6.0; // P Panel Density [3.0, 10.0, 1.0]
const float P_SPIN_SPEED = 0.42; // P Turntable Speed [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Cage / Baked Split [0.0, 1.0, 0.02]
// Low-poly beveled cube-octahedron base mesh
float sdLowPoly(vec3 p) {
vec3 ap = abs(p);
float dBox = max(ap.x, max(ap.y, ap.z)) - 0.52;
float dOct = (ap.x + ap.y + ap.z - 0.82) * 0.57735;
return max(dBox, dOct);
}
// High-poly sculpted height detail projected onto each face's local tangent coordinates
float evalSculptHeight(vec2 uv, float freq) {
vec2 c = abs(uv) - 0.36;
float bevelPanel = smoothstep(0.04, -0.04, max(c.x, c.y));
vec2 g = fract(uv * freq) - 0.5;
float rivet = smoothstep(0.20, 0.08, length(g)) * step(0.24, max(abs(uv.x), abs(uv.y))) * step(max(abs(uv.x), abs(uv.y)), 0.40);
float emblem = smoothstep(0.03, -0.01, abs(length(uv) - 0.18));
float groove = smoothstep(0.022, 0.005, abs(uv.x)) * step(abs(uv.y), 0.32)
+ smoothstep(0.022, 0.005, abs(uv.y)) * step(abs(uv.x), 0.32);
return bevelPanel * 0.35 + rivet * 0.55 + emblem * 0.42 - clamp(groove, 0.0, 1.0) * 0.32;
}
vec3 evalBakedTangentNormal(vec2 uv, float freq, float depth) {
float e = 0.006;
float h = evalSculptHeight(uv, freq);
float hx = evalSculptHeight(uv + vec2(e, 0.0), freq);
float hy = evalSculptHeight(uv + vec2(0.0, e), freq);
return normalize(vec3(-(hx - h) / e * 0.045 * depth, -(hy - h) / e * 0.045 * depth, 1.0));
}
vec3 calcLowNormal(vec3 p) {
vec2 e = vec2(0.002, 0.0);
return normalize(vec3(
sdLowPoly(p + e.xyy) - sdLowPoly(p - e.xyy),
sdLowPoly(p + e.yxy) - sdLowPoly(p - e.yxy),
sdLowPoly(p + e.yyx) - sdLowPoly(p - e.yyx)
));
}
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 sx = fragCoord.x / max(iResolution.x, 1.0);
float split = clamp(P_SPLIT, 0.0, 1.0);
bool showBaked = sx >= split;
float depth = clamp(P_SCULPT_DEPTH, 0.1, 2.0);
float freq = clamp(floor(P_RIVET_FREQ + 0.5), 2.0, 12.0);
float a = iTime * max(P_SPIN_SPEED, 0.0) + 0.45;
float bAng = 0.36;
mat3 ry = mat3(cos(a), 0.0, sin(a), 0.0, 1.0, 0.0, -sin(a), 0.0, cos(a));
mat3 rx = mat3(1.0, 0.0, 0.0, 0.0, cos(bAng), -sin(bAng), 0.0, sin(bAng), cos(bAng));
mat3 rot = rx * ry;
vec3 ro = vec3(0.0, 0.04, 2.15);
vec3 rd = normalize(vec3(uv, -1.52));
vec3 col = mix(vec3(0.06, 0.07, 0.10), vec3(0.16, 0.20, 0.28), uv.y + 0.5);
float t = 0.05;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec3 op = rot * (ro + rd * t);
float d = sdLowPoly(op);
if (d < 0.0018) { hit = true; break; }
t += d;
if (t > 6.0) break;
}
if (hit) {
vec3 op = rot * (ro + rd * t);
vec3 nObj = calcLowNormal(op);
// Project local face UV and tangent basis on each faceted face
vec3 an = abs(nObj);
vec2 fuv;
vec3 tObj, bObj;
if (an.x >= an.y && an.x >= an.z) {
fuv = op.zy;
tObj = vec3(0.0, 0.0, 1.0);
bObj = vec3(0.0, 1.0, 0.0);
} else if (an.y >= an.x && an.y >= an.z) {
fuv = op.xz;
tObj = vec3(1.0, 0.0, 0.0);
bObj = vec3(0.0, 0.0, 1.0);
} else {
fuv = op.xy;
tObj = vec3(1.0, 0.0, 0.0);
bObj = vec3(0.0, 1.0, 0.0);
}
// Orthogonalize tangent frame for chamfered octant faces
tObj = normalize(tObj - nObj * dot(tObj, nObj));
bObj = cross(nObj, tObj);
vec3 tn = evalBakedTangentNormal(fuv, freq, depth);
vec3 bakedN = normalize(transpose(rot) * (tObj * tn.x + bObj * tn.y + nObj * tn.z));
vec3 flatN = normalize(transpose(rot) * nObj);
vec3 L = normalize(vec3(0.62, 0.74, 0.58));
vec3 v = -rd;
if (!showBaked) {
// Left: Tangent-space normal map RGB (purple/cyan/pink) baked directly onto the faceted low-poly cage
vec3 nmRGB = tn * 0.5 + 0.5;
float ndl = 0.55 + 0.45 * max(dot(flatN, L), 0.0);
// Facet edge wireframe highlight
vec3 ap = abs(op);
float edge = smoothstep(0.025, 0.004, abs((ap.x + ap.y + ap.z - 0.82) * 0.57735 - (max(ap.x, max(ap.y, ap.z)) - 0.52)));
col = nmRGB * ndl + vec3(0.95, 0.92, 0.45) * edge * 0.45;
} else {
// Right: Identical low-poly silhouette shaded with the baked tangent-space normal map
vec3 H = normalize(L + v);
float ndl = max(dot(bakedN, L), 0.0);
float ndh = max(dot(bakedN, H), 0.0);
float rim = pow(1.0 - max(dot(bakedN, v), 0.0), 3.0);
vec3 alb = vec3(0.66, 0.54, 0.36);
float spec = pow(ndh, 42.0) * 1.1;
vec3 sky = mix(vec3(0.14, 0.18, 0.26), vec3(0.38, 0.48, 0.66), 0.5 + 0.5 * bakedN.y);
col = alb * (vec3(1.25, 1.15, 0.98) * ndl + sky * 0.52) + vec3(1.0, 0.88, 0.68) * (spec + rim * 0.25);
}
}
// Lower-left corner: inset 2D tangent-space normal map texture tile preview
vec2 insetUv = (fragCoord / max(iResolution.y, 1.0)) - vec2(0.05, 0.06);
if (!showBaked && insetUv.x > 0.0 && insetUv.x < 0.26 && insetUv.y > 0.0 && insetUv.y < 0.26) {
vec2 tileUv = (insetUv / 0.26 - 0.5) * 0.95;
vec3 tn = evalBakedTangentNormal(tileUv, freq, depth);
col = tn * 0.5 + 0.5;
vec2 b = abs(insetUv / 0.26 - 0.5);
if (max(b.x, b.y) > 0.48) col = vec3(0.95, 0.96, 1.0);
}
float sep = smoothstep(0.0035, 0.0008, abs(sx - 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 |
|---|---|---|---|
| normal-map-baking-live | Tesla T4 1920x1080 | 7.06× baseline (moderate) · 0.232 ms / 0.246 ms | opengl-timer-query · 32 frames · GPU Weight Atlas · Colab T4 sweep |
| normal-map-baking-live | NVIDIA L4 1920x1080 | 5.99× baseline (light) · 0.095 ms / 0.099 ms · 2.4× faster on L4 | opengl-timer-query · Cross-architecture validation |
| normal-map-baking-live | NVIDIA A100-SXM4-40GB 1920x1080 | 4.96× baseline (light) · 0.143 ms / 0.145 ms · 1.6× faster on A100 | opengl-timer-query · Cross-architecture validation |
Lineage
Crosses
- Normal mapping with MikkTSpace: The baker writes tangent-space normals; MikkTSpace guarantees the shader decodes them with the same basis.
- xatlas: Provides the non-overlapping UV layout that the bake needs on the low-poly mesh.
Sources
- primaryDiogo Teixeira. Chapter 22. Baking Normal Maps on the GPU. developer.nvidia.com.Verified via live page · 2026-11-29
- secondaryJonathan Cohen, Marc Olano, Dinesh Manocha (1998). Appearance-preserving simplification. Proceedings of the 25th annual conference on Computer graphics and interactive techniques - SIGGRAPH '98.Verified via crossref · 2026-11-29doi:10.1145/280814.280832