Skip to main content

Baked lighting

Realtime lights are cheap until you want soft shadows, light that bounces off a red wall onto the floor, or corners that are darker because the sky can't reach them. Generate Lighting works these out once, in the editor, and stores them in pictures: the light maps. The game then only reads the picture, which is fast on phones too. It works like Unity's baked lightmaps.

Baking is for things that never move: floors, walls, buildings, rocks, furniture. Anything that moves keeps realtime light.

Bake a scene​

  1. Select each object that never moves and turn on Contribute GI (under Shape & look, below the shadow switches). This is Unity's static flag.
  2. Select the sun (or a lamp) and set its Mode to Baked.
  3. Open the Scene tab → Lighting → Generate Lighting.

The bar shows how far it got; Cancel stops it. When it is done the scene view shows the baked light, and the pictures are in Files → Lightmaps → scene name. Press Play: the game looks the same.

Moved something, or changed a light? Press Generate Lighting again. Clear Baked Data takes the light maps off and the lights light the scene as before.

Light Mode​

ModeWhile the game runsIn the light maps
Realtime (the default)Lights everything, with realtime shadows.Nothing.
MixedLights everything, with realtime shadows.The light it bounces off surfaces, and with Lighting Mode Shadowmask its shadows from static objects.
BakedNothing (once the scene is baked).Its light, its soft shadows and the light it bounces.

A Baked light no longer lights moving objects directly once the scene is baked, the same as in Unity: they get its light from light probes. For an outdoor scene with a player walking around, a good start is a Mixed sun (realtime light and shadows on everything, baked bounce light and sky shadows on the scenery) plus Baked lamps for the decoration.

Shadowmask​

With the scene's Lighting Mode on Shadowmask (the default, as in Unity), Generate Lighting also bakes where each Mixed light is blocked by static objects: the shadowmask. The light itself stays realtime, so moving objects are lit and cast shadows as before, but the scenery's shadows from scenery come from the bake. They are soft, reach as far as the scene goes, and are there even on a device with realtime shadows off.

  • Up to 4 Mixed lights with Casts shadow get a shadowmask (Unity's limit too). Another one keeps realtime shadows only.
  • A static object's shadowmask picture sits next to its light map in Files → Lightmaps.
  • Moving objects take the scenery's shadows from light probes: bake a Light probe volume where they go.
  • Move or turn a Mixed light after baking and its baked shadows switch off (realtime shadows only) until you bake again.

How the bake and realtime shadows share the work is set per quality level in Project settings, as in Unity:

Shadowmask ModeStatic objectsMoving objects
Distance Shadowmask (High, Medium)Realtime shadows near the camera, the shadowmask beyond.Realtime shadows near the camera, probes beyond.
Shadowmask (Low)Shadows only from the shadowmask: they cast no realtime shadows, which saves time on phones.Realtime shadows of moving objects; the scenery's shadows from probes.

Baked Indirect bakes only the Mixed lights' bounced light, as before.

Baked shadow angle (sun) and Baked shadow radius (lamp, spotlight) make a Baked light's shadows, and a Mixed light's shadowmask, soft: the wider, the softer, like a big lamp or a hazy sun. 0 gives sharp shadows.

The shader sky's sun​

With Background → Sky (sun and clouds) and Sun light on, the sky's sun is a light too, with its own Sun light mode (Realtime, Mixed or Baked, as in the table above). On Baked the sun's light and shadows go into the light maps and probes, soft as the sun's disc: a bigger Sun size gives softer shadows. It is the same as Unity's sun source light. The sky's own light (Light with sky) is baked whatever the mode.

The scene's Ambient light, Sky lights and the light of the sky picture (Light with sky, or a shader sky) are always baked into the light maps of static objects. They come with shadows: under a table and in the corners of a room it is darker. Reflections of the sky stay realtime.

Light probes​

Light maps only cover objects that never move. For the player, enemies and anything else that moves, add a Light probe volume (Unity's Light Probe Group): Add component → Light probe volume on an empty object, then set its box around the area where things move.

SettingWhat it does
SizeThe box, in metres, centred on the object. The object's scale stretches it and turning the object turns it. The probes always sit in rows along the world axes, as in Unity's probe volumes: a turned box is filled by the world-aligned box around it, which the scene view draws as a fainter outline.
Probe spacingMetres between probes. Closer probes follow shadows and colours more tightly but take longer to bake. Probes shows how many you get.

Generate Lighting then stores, at every probe, the light arriving from every direction: Baked lights with their shadows, the sky and the light bounced off the scenery. A moving object inside the box takes its light from the probes around it. A ball rolling next to a red wall turns reddish on that side, and a character walking under a roof gets darker. Select the volume to see its probes as dots (yellow once baked).

  • With a baked volume in the scene, moving objects take their sky and ambient light from the probes, and not from the flat Ambient light or straight from the sky picture, so it comes with shadows. Realtime and Mixed lights still light them directly.
  • Several volumes can cover different areas. An object outside all of them takes the light of the nearest one.
  • Probes that end up inside walls take the light of their neighbours.
  • Probes give soft, low-detail light. A sharp shadow edge falls between probes and blurs. Realtime or Mixed lights give moving objects sharp shadows.
  • Moving the volume after baking does nothing until you bake again.

Prefabs​

Baked light belongs to the scene, as in Unity. A baked prefab copy doesn't count its light map as an override: Apply never puts light maps into the prefab, and Revert or a change to the prefab keeps the copy's bake. A prefab made from a baked object holds no light map, so a fresh copy starts with realtime light until you bake again.

Glowing materials​

A material with a Glow color lights its surroundings in the bake, as Unity's emissive materials do: lava lights the cave walls, a neon sign tints the street, a screen lights the desk in front of it.

  1. Give the material a Glow color and raise Glow intensity (2–10 for light you can see on nearby surfaces).
  2. Turn on Contribute GI on the object.
  3. Press Generate Lighting.

The glow lights the light maps and the light probes, so moving objects near it pick up its colour too. Indirect intensity makes it stronger or weaker, as it does bounced light. An Emissive map counts with its average colour. To keep a glow out of the bake, set the material's Global Illumination to None. Unlit materials don't light the bake.

Lighting settings​

SettingWhat it does
Lighting ModeWhat is baked of Mixed lights: Shadowmask (their bounced light and their shadows from static objects, see Shadowmask) or Baked Indirect (only their bounced light).
LightmapperWhere the light is traced. Progressive GPU (the default) uses the graphics card and is several times faster: a scene that takes 15 s on the processor takes about 3 s on a laptop's built-in graphics, less on a gaming card. Progressive CPU uses the processor's cores. Both give the same light. Where the graphics card can't do it (an old browser, more than 32 lights), the CPU one runs by itself.
Lightmap resolutionPixels per metre on every static object (10 = a 1 m box side gets 10 × 10). Higher is sharper and slower to bake.
Max lightmap sizeThe size of the light map pictures. The static objects share them (Unity's lightmap atlas): as many objects as fit go in one picture, then a second picture starts. A big object that would need more than one picture gets coarser pixels.
Lightmap CompressionHow the light map pictures are stored. High Quality (the default, as in Unity), Normal Quality and Low Quality are lossy WebP: smaller files with small colour errors (High Quality is about 4 × smaller than None, and hard to tell apart). None keeps every pixel exactly (lossless WebP).
Direct samplesShadow rays per light for each pixel. More gives smoother soft shadows.
Indirect samplesRays per pixel for sky light and bounced light. More gives less speckle.
BouncesHow many times light bounces off surfaces (0 = none).
Indirect intensityMore or less bounced light.
FilterSmooths the speckle that low sample counts leave.

Each static object also has Scale in lightmap (under Contribute GI): 2 gives it twice the pixels per metre (a floor close to the camera), 0.5 half (a far-away cliff).

Good to know​

  • The light maps are made for the object's shape and scale. Change either and that object shows realtime light again until you press Generate Lighting. Moving it keeps the old picture, now in the wrong place, so bake again after moving things.
  • Static objects block and bounce light in the bake; moving objects don't. A static object also needs Casts shadow on to cast baked shadows.
  • Unlit and custom-shader materials take no light map. Imported models with skinned (animated) meshes are not baked.
  • The light maps are often the biggest part of a game's download. Keep Lightmap Compression on High Quality, or lower it for a smaller file.
  • Every light map picture is one more for the phone to load. Keep Lightmap resolution as low as looks good and lower Scale in lightmap on large, plain surfaces, so fewer pictures are needed.
  • The bake runs on your device in the background. Phones bake too, more slowly. While Progressive GPU bakes, animated materials in the scene view stand still, so the graphics card is free for the bake; they move again when it is done.
  • A material's own Light map slot (see Texture maps) is for pictures baked in another tool. A baked object uses its Generate Lighting map instead.