Lightmap Baking
Precomputes the lighting of static surfaces offline into textures addressed by a second, non-overlapping UV set, then samples them at runtime for essentially free GI.
Also known as baked GI, precomputed lighting, lightmapping
In the family Light transport & global illumination, precomputed GI
Where it runs
Built inOfficial add-onPluginNone foundNot researched
| Engine | Support | How |
|---|---|---|
| three.js r187 | Official add-on | import { LightMapper } from 'three/addons/lighting/LightMapper.js' docs WebGPURenderer only. |
| Babylon.js 9.38.0 | None found | |
| Godot 4.7 | Built in | Add a LightmapGI node and bake (LightmapGI.bake()) docs GPU lightmapper (LightmapperRD) bakes lightmaps with denoising. |
| Unity | Built in | Window > Rendering > Lighting > Lightmapping Settings > Progressive GPU/CPU docs Progressive Lightmapper (CPU/GPU) in URP and HDRP. |
| Unreal 5.7 | Official add-on | Enable the GPU Lightmass plugin; World Settings > Lightmass; build lighting with GPU Lightmass (or built-in CPU Lightmass) docs |
| Blender 5.2 | Built in | Properties > Render > Bake (Cycles), Bake button docs |
| WebGPU W3C | None found | |
| Metal | None found |
How it works
Every static mesh gets a lightmap UV atlas: a unique, non-overlapping unwrap with padding between charts so bilinear filtering does not bleed. Texels of the atlas are mapped back to world positions and normals. A baker then computes the irradiance (or directional radiance) at each texel with an offline integrator, typically Unidirectional Path Tracing with many samples, and writes the results into a texture. Storage formats include RGB irradiance, plus a dominant light direction or low-order spherical-harmonic or spherical-Gaussian coefficients so normal maps still respond to the light.
After baking, a denoiser cleans the noisy output and a dilation pass fills texels outside the charts to avoid seams. At runtime the shader multiplies albedo by the sampled lightmap value, optionally combined with real-time direct light and Irradiance Volumes and Light Probes probes for dynamic objects.
The baker is the offline system; the runtime cost is one texture fetch per pixel.
When to choose it
Reach for it when
- static scenes need free high quality gi at runtime
- mobile game needs precomputed lighting
- lighting looks flat with only direct lights
- bake shadows and bounce light into textures
Choose it for static scenes, mobile and web targets, and anything with a tight frame budget where high-quality interreflection and soft shadows must be paid for once.
Prefer Irradiance Volumes and Light Probes for dynamic objects and for volumes without UVs. Prefer Dynamic Diffuse Global Illumination (DDGI), SDF-Based Software Ray Tracing GI (Lumen-style) or Surfel-Based Global Illumination (GIBS) when lights or geometry move at runtime. Prefer Precomputed Radiance Transfer when the light changes but the geometry is rigid.
Field marks
- Seams along chart borders from missing padding or inconsistent texel density between adjacent charts
- Light and shadow bleeding where thin walls share texels from both sides
- Static only: moving lights or doors leave baked shadows behind, requiring a hybrid with dynamic direct light
- Atlas packing waste and long iteration times: any geometry or light edit requires a rebake
Presets
Lightmap Baking — coarse UV-chart texels & seams (left) vs high-res directional baked lightmap (right)
{
"P_TEXEL_RES": 10,
"P_BOUNCE_INT": 1.25,
"P_CHART_VIS": 0.75,
"P_SPLIT": 0.48
}Show GLSL (139 lines)
const float P_TEXEL_RES = 10.0; // P Low-Res Texels [4.0, 20.0, 1.0]
const float P_BOUNCE_INT = 1.25; // P Baked GI Gain [0.3, 2.2, 0.05]
const float P_CHART_VIS = 0.75; // P UV Chart Grid [0.0, 1.5, 0.05]
const float P_SPLIT = 0.48; // P Coarse / Fine Split [0.0, 1.0, 0.02]
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);
}
// Sunlit architectural gallery with skylight aperture and sculpted bench + archway
vec2 mapScene(vec3 p) {
vec2 res = vec2(p.y + 0.85, 1.0);
float dC = 1.05 - p.y; if (dC < res.x) res = vec2(dC, 1.0);
float dB = p.z + 1.45; if (dB < res.x) res = vec2(dB, 2.0);
float dL = p.x + 1.35; if (dL < res.x) res = vec2(dL, 3.0);
float dR = 1.35 - p.x; if (dR < res.x) res = vec2(dR, 4.0);
float dBench = sdBox(p - vec3(-0.35, -0.58, -0.35), vec3(0.42, 0.27, 0.24)) - 0.02;
if (dBench < res.x) res = vec2(dBench, 5.0);
float dPed = sdBox(p - vec3(0.55, -0.45, -0.55), vec3(0.24, 0.40, 0.24)) - 0.02;
if (dPed < res.x) res = vec2(dPed, 5.0);
float dSph = length(p - vec3(0.55, 0.14, -0.55)) - 0.22;
if (dSph < res.x) res = vec2(dSph, 6.0);
return res;
}
vec3 calcNormal(vec3 p) {
vec2 e = vec2(0.0022, 0.0);
return normalize(vec3(
mapScene(p + e.xyy).x - mapScene(p - e.xyy).x,
mapScene(p + e.yxy).x - mapScene(p - e.yxy).x,
mapScene(p + e.yyx).x - mapScene(p - e.yyx).x
));
}
// Evaluate precomputed static lightmap irradiance at UV-mapped surface point p
vec3 bakeLightmap(vec3 p, vec3 n, float giGain) {
// Warm angled skylight beam hitting floor & bench + soft indirect bounce
vec3 sunDir = normalize(vec3(0.45, 0.82, 0.35));
float tPlane = (1.05 - p.y) / sunDir.y;
vec2 skyHit = p.xz + sunDir.xz * tPlane;
float inBeam = smoothstep(0.52, 0.34, abs(skyHit.x + 0.15)) * smoothstep(0.42, 0.26, abs(skyHit.y + 0.35));
float ndl = max(dot(n, sunDir), 0.0);
// Soft shadow occlusion inside baked pass
float sh = 1.0;
float ts = 0.04;
for (int i = 0; i < 16; i++) {
float d = mapScene(p + sunDir * ts).x;
sh = min(sh, 5.5 * d / max(ts, 0.04));
ts += clamp(d, 0.03, 0.20);
if (sh < 0.05 || ts > 2.2) break;
}
vec3 sunDirect = vec3(2.4, 2.05, 1.55) * ndl * inBeam * clamp(sh, 0.0, 1.0);
// Multi-bounce color bleed from sunlit warm terracotta floor patch & cool sky fill
float floorBounce = exp(-length(p - vec3(-0.35, -0.85, -0.45)) * 0.95);
vec3 indirect = vec3(0.92, 0.56, 0.26) * floorBounce * 0.72;
indirect += vec3(0.28, 0.46, 0.74) * (0.45 + 0.55 * max(n.y, 0.0)) * 0.48;
float ao = clamp(0.35 + 0.65 * mapScene(p + n * 0.26).x / 0.26, 0.16, 1.0);
return sunDirect + indirect * giGain * ao;
}
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 isHiRes = screenX >= split;
float texRes = clamp(floor(P_TEXEL_RES + 0.5), 4.0, 22.0);
float giGain = clamp(P_BOUNCE_INT, 0.2, 2.4);
float chartVis = clamp(P_CHART_VIS, 0.0, 1.5);
float camAng = 0.14 * sin(iTime * 0.42);
vec3 ro = vec3(0.32 * sin(camAng), 0.06, 2.38);
vec3 rd = normalize(vec3(uv, -1.52));
vec3 col = vec3(0.03);
float t = 0.0;
float matId = 0.0;
bool hit = false;
for (int i = 0; i < 64; i++) {
vec2 h = mapScene(ro + rd * t);
if (h.x < 0.002) { hit = true; matId = h.y; break; }
t += h.x;
if (t > 9.0) break;
}
if (hit) {
vec3 p = ro + rd * t;
vec3 n = calcNormal(p);
// Triplanar non-overlapping UV2 chart coordinates per surface orientation
vec3 an = abs(n);
vec2 lmUV = (an.x > an.y && an.x > an.z) ? p.yz : ((an.y > an.z) ? p.xz : p.xy);
vec3 alb = vec3(0.76, 0.74, 0.70);
if (matId > 2.5 && matId < 3.5) alb = vec3(0.84, 0.44, 0.26);
if (matId > 3.5 && matId < 4.5) alb = vec3(0.32, 0.56, 0.70);
if (matId > 5.5) alb = vec3(0.88, 0.82, 0.68);
if (!isHiRes) {
// Left: low-texel-density quantized lightmap showing blocky texels & chart-edge bleeding
float stepUV = 1.0 / max(texRes * 0.5, 2.0);
vec3 pQ = (floor(p / stepUV) + 0.5) * stepUV;
vec3 lmCoarse = bakeLightmap(pQ, n, giGain);
col = alb * lmCoarse;
// Texel cell borders and UV chart seam highlight
vec2 tf = abs(fract(lmUV / stepUV - 0.5) - 0.5);
float tGrid = smoothstep(0.065, 0.015, min(tf.x, tf.y));
col = mix(col, vec3(0.08, 0.14, 0.22), tGrid * 0.48 * min(chartVis, 1.2));
} else {
// Right: high-resolution directional baked lightmap + micro-bump normal shading
vec3 lmFine = bakeLightmap(p, n, giGain);
// Directional lightmap dominant vector adds crisp normal-map relief to static bounce
vec3 domDir = normalize(vec3(0.35, 0.80, 0.30));
float micro = sin(lmUV.x * 46.0) * sin(lmUV.y * 46.0) * 0.06;
vec3 bumpedN = normalize(n + vec3(micro, 0.0, -micro));
float dirScale = 0.78 + 0.36 * max(dot(bumpedN, domDir), 0.0);
col = alb * lmFine * dirScale;
}
// Bright skylight window opening on ceiling
if (p.y > 1.03 && abs(p.x + 0.15) < 0.44 && abs(p.z + 0.35) < 0.34) {
col = vec3(2.8, 3.2, 3.8);
}
}
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 |
|---|---|---|---|
| lightmap-baking-live | Tesla T4 1920x1080 | 26.9× baseline (heavy) · 0.834 ms / 0.947 ms | opengl-timer-query · 36 frames · GPU Weight Atlas · Colab T4 sweep |
| lightmap-baking-live | NVIDIA L4 1920x1080 | 27.8× baseline (heavy) · 0.441 ms / 0.446 ms · 1.9× faster on L4 | opengl-timer-query · Cross-architecture validation |
| lightmap-baking-live | NVIDIA A100-SXM4-40GB 1920x1080 | 17.2× baseline (moderate) · 0.495 ms / 0.502 ms · 1.7× faster on A100 | opengl-timer-query · Cross-architecture validation |
Crosses
- Baking trained NeRF radiance fields into directional mesh lightmaps: Treating a trained NeRF volume as a directional incident-radiance oracle during UV lightmap baking distills expensive neural ray-marching into static L1/L2 spherical-harmonic lightmaps that run at 120 FPS on any WebGL2 or mobile mesh renderer.
- Neural-compressed directional lightmaps: High-resolution directional lightmaps stored as small latent grids decoded in the shader. The bands of a spherical-harmonic lightmap are strongly correlated, which joint neural encoding can exploit better than compressing each channel on its own.
- Irradiance Volumes and Light Probes: Volume probes baked in the same pass light dynamic objects consistently with the static lightmap.
Sources
- primaryMichal Iwanicki (2013). Lighting technology of the last of us. ACM SIGGRAPH 2013 Talks.Verified via crossref · 2026-11-29doi:10.1145/2504459.2504484
- implementationands (2016). ands/lightmapper. A C/C++ single-file library for drop-in lightmap baking. Just use your existing OpenGL renderer to bounce light!GitHub API · no license declared · 2026-11-29