Light baking

Also known as: lightmap · lightmap baking

On this page 7

Light baking is the process of precomputing lighting offline and storing the result in textures, vertex data or probe volumes, so that a renderer can display expensive effects such as global illumination, soft shadows and ambient occlusion without calculating them every frame. In Real-time 3D, it is the classic way to make games, architectural walkthroughs and web scenes look physically plausible on hardware that could never trace that light interactively.

The stored texture is usually called a lightmap, and the procedure is often named lightmap baking. The core idea is a trade: the engine spends minutes or hours of build time once, then pays only a texture lookup per pixel at runtime. The price is rigidity, because baked light describes one fixed arrangement of geometry and light sources.

How light baking computes and stores illumination

A baker simulates light transport through the static parts of a scene and writes the arriving energy into storage that the runtime shader can sample. Most modern bakers use path tracing or photon mapping on the CPU or GPU, firing rays from each lightmap texel into the scene and accumulating direct and indirect bounces until the estimate converges.

Before any rays are cast, every static mesh needs a second, non-overlapping UV set, often called UV2 or the lightmap UV channel. Unlike the texture UVs used for materials, these coordinates must give each surface a unique area of the atlas, because two surfaces sharing texels would receive the same lighting. The baker then packs all charts into one or more lightmap atlases and adds padding to prevent bleeding between neighboring charts.

The process runs in a predictable sequence. The following table summarizes the main stages and what each one controls.

StageWhat happensMain quality lever
UV unwrappingUnique lightmap UVs are generated per meshChart padding and distortion
Atlas packingCharts are arranged into shared texturesTexel density and atlas size
Light transportRays gather direct and bounced lightSample count and bounce count
DenoisingA filter removes Monte Carlo noiseDenoiser type and strength
Dilation and compressionEdges are extended, data is encodedTexture format and bit depth
Stages of a typical bake

At runtime, the fragment shader multiplies the material albedo by the sampled lightmap value and adds any remaining real-time contributions, such as specular highlights or dynamic lights. That single sample replaces what would otherwise be thousands of ray evaluations per pixel.

What baked data can contain

Baked data ranges from a single grayscale channel to directional encodings that preserve some sense of where light comes from. Choosing the representation is a balance between memory footprint, visual fidelity and compatibility with normal maps.

RepresentationStoresTypical use
Ambient occlusion mapShadowing from nearby geometryContact darkening on props
Irradiance lightmapIncoming diffuse light as RGB colorStatic walls, floors, terrain
Directional lightmapDominant light direction plus colorNormal-mapped static surfaces
Spherical harmonics probesLow-frequency light at points in spaceLighting moving characters
Reflection probesPrefiltered environment cubemapsGlossy specular reflections
Vertex lightingLight values per mesh vertexLow-end devices, dense meshes
Common baked lighting representations

Lightmaps are normally stored in high dynamic range, using formats such as RGBM, BC6H or half-float textures, because bounced light in a sunny room easily spans several orders of magnitude. Storing them in plain 8-bit sRGB causes visible banding and clipped highlights.

Light baking compared with real-time lighting

Baked and real-time lighting are complementary rather than competing, and most shipping projects use a mixed lighting model. Baking handles static indirect light, while real-time techniques such as shadow mapping, screen space ambient occlusion and screen space reflections cover moving objects and view-dependent effects.

AspectLight bakingFully dynamic lighting
Runtime costVery low, one texture sampleHigh, scales with lights and bounces
Indirect light qualityHigh, many bounces possibleApproximate unless ray traced
Moving lights or geometryNot supported for baked partsFully supported
Iteration speedSlow, requires rebakeImmediate feedback
Memory useGrows with texel densityMostly shadow maps and buffers
Hardware targetMobile, web, VR, consolesMid to high-end GPUs
Baked versus dynamic approaches

Real-time global illumination systems now close part of the gap, but they still cost several milliseconds per frame on capable hardware. On a mobile headset with a budget of about 11 to 14 milliseconds per frame, baking often remains the only way to show convincing bounced light.

Configuring a bake for quality and memory

The most influential setting is texel density, the number of lightmap texels per world unit. Doubling linear density quadruples memory and bake time, so experienced artists assign higher density to surfaces near the camera and much lower density to distant or hidden ones.

The decision table below lists frequent situations and sensible starting strategies.

SituationRecommended approachReason
Static interior with fixed sunFull bake with directional lightmapsBest indirect quality at minimal cost
Day-night cycleBake indirect only or use probesDirect light must move
WebGL product viewerBake AO and lighting into texturesKeeps shaders simple and fast
Characters in baked levelsLight probes or probe volumesMoving objects cannot use lightmaps
Large open terrainLow density plus real-time shadowsLightmap memory would explode
Choosing a baking strategy

Libraries such as Three.js and Babylon.js read baked lightmaps through a second UV channel, which makes offline baking in a DCC tool a common workflow for browser scenes. Engine-integrated bakers add light probe placement, mixed-mode shadows and incremental rebakes that reprocess only changed areas.

Limitations and common baking errors

The fundamental limitation is that baked light is frozen in time: opening a door, destroying a wall or moving a lamp leaves the old lighting in place. Teams work around this with multiple lightmap sets, blended probe data or a hybrid real-time layer, all of which add memory and complexity.

  • Light leaking appears when thin walls or overlapping geometry let rays pass where they should not; thicker walls or closed meshes usually fix it.
  • Seams show at chart boundaries when padding is too small or UVs are split along visible edges.
  • Blotchy noise results from too few samples or an aggressive denoiser that smears detail.
  • Shadow acne and stair-stepping come from insufficient texel density on large surfaces.
  • Mismatched specular occurs when baked diffuse light and real-time reflections disagree in intensity.

A further misconception is that baking makes scenes cheap in every respect. Large atlases increase download size and GPU memory, and streaming them demands careful mipmapping and texture streaming plans.

The short version

Calculating how light bounces around a room is slow. Light baking does that work once, ahead of time, and saves the answer as an image painted onto the walls, floors and furniture.

When the scene runs, the computer simply reads those stored shadows and glows instead of working them out again. It is like painting the lighting onto a theater set before the show: it looks rich and costs nothing during the performance, but nothing can move without the paint looking wrong.

Where it makes a difference

A small studio builds a virtual reality tour of a museum hall for a standalone headset that must hold 72 frames per second. Rendering sunlight through tall windows, bouncing off a marble floor and filling the side galleries in real time would exceed the GPU budget several times over.

The team marks the architecture as static, generates lightmap UVs, sets a texel density of 20 texels per meter near walkways and 4 in the ceiling vaults, and bakes three bounces overnight. Visitors and a rotating sculpture receive light from a grid of spherical harmonics probes. The final scene uses about 90 MB of compressed lightmaps, runs at a steady frame rate with headroom, and shows soft bounced light that a purely dynamic setup could not deliver on that device.