๐บ๏ธ Lesson 8.2: Lightmapping & Light Probes
In Lesson 8.1 you decided which lights to bake. Now you'll bake them. Lightmapping precomputes rich, bounced lighting into a texture so it costs almost nothing at runtime โ and Light Probes carry that same baked light onto your moving characters so they never look pasted-on. This is how good-looking scenes stay fast.
๐ฏ Learning Objectives
By the end of this lesson, you will be able to:
- Mark objects Static and enable Contribute GI so they take part in a bake
- Navigate the Lighting window (Scene, Environment, Baked settings)
- Generate lightmaps and read the resulting lightmap textures
- Place a Light Probe Group so moving objects receive baked light
- Use a Reflection Probe to give surfaces believable local reflections
- Diagnose the common bake problems (dark movers, seams, giant lightmaps, long bake times)
Estimated Time: 45 minutes ยท Prerequisite: Lesson 8.1 (URP Lighting: Real-time & Baked)
In This Lesson
Static & Contribute GI
The lightmapper only bakes objects it's told won't move. You tell it by marking an object Static โ the dropdown at the top-right of the Inspector, next to the object's name. Clicking the arrow reveals individual static flags; the one that matters for lighting is Contribute GI.
- Contribute GI on โ this object is baked into the lightmap: it receives baked light and bounces light onto its neighbours.
- Its Receive Global Illumination setting (in the Mesh Renderer) then chooses Lightmaps (baked into a texture โ for static scenery) or Light Probes (sampled at runtime โ for smaller/detail objects).
Rule of thumb: walls, floors, big rocks, buildings โ anything bolted down โ get Contribute GI. The player, enemies, doors, and pickups do not; they'll be lit by probes instead.
๐ Definition
Lightmap: a texture that stores precomputed lighting (direct + bounced) for the static surfaces of a scene. At runtime the shader simply reads this texture instead of computing lighting, which is why baked light is nearly free.
โ ๏ธ Static is a promise you can't break
If you mark an object Static and then move it at runtime, its baked lighting and shadow stay behind in the old spot โ a floating shadow, a dark ghost. Only mark things Static that genuinely never move.
The Lighting Window
Open Window โธ Rendering โธ Lighting. This is mission control for baking. It has three tabs you'll live in: Scene (the active Lighting Settings asset and all bake parameters), Environment (skybox + ambient, from Lesson 8.1), and Baked Lightmaps (the generated textures). Here is the Scene tab, rebuilt as you'll see it:
๐ก Where's my Lighting Settings asset? The Scene tab edits a Lighting Settings asset (create one via New Lighting Settings). Saving it as an asset lets multiple scenes share the same bake configuration โ handy once your project grows.
Generating Lightmaps
With static objects flagged and Baked Global Illumination on, click Generate Lighting. Unity's Progressive Lightmapper traces light around the scene and refines the result, painting it progressively into lightmap textures. A progress bar shows the number of texels remaining.
When it finishes, open the Baked Lightmaps tab to see the generated textures โ mottled orange-and-shadow images that are your scene's lighting, flattened. Each static object's UVs map into one of these textures.
Two knobs govern the trade-off:
- Lightmap Resolution (texels per unit) โ higher = sharper shadows and gradients, but larger textures and much longer bakes. Start around 20โ40 for gameplay scenes.
- Lightmap Size โ the pixel dimensions of each atlas (e.g. 1024). Bigger fits more objects per texture but uses more memory.
โ Pro Tip
Turn Auto Generate off for anything but the tiniest scene. Auto mode re-bakes on every tiny change and will grind your Editor to a halt. Bake manually when you're ready to see the result.
Light Probes for Movers
Baked light lives in a lightmap that only covers static surfaces โ so your player, enemies, and physics props get none of it. That's the dark-character problem from Lesson 8.1. The fix is a Light Probe Group.
A light probe is a point in space that samples the baked lighting at that spot โ its colour and direction. Scatter a cloud of them through the playable volume (GameObject โธ Light โธ Light Probe Group, then Edit Light Probes to add and drag points). At runtime, a moving object reads the probes around it and blends them, so it picks up the room's baked tone โ warm near a baked torch, cool in shadow.
๐ Definition
Light Probe: a stored sample of baked lighting at a single point. Dynamic objects interpolate between the nearest probes to receive baked global illumination they otherwise couldn't, because they aren't in the lightmap.
โ ๏ธ Place probes where lighting changes
You don't need an even grid. Cluster probes where light shifts โ doorways, the edge of a shadow, the mouth of a cave โ and space them out across uniformly lit areas. Probes in a straight coplanar line can't interpolate volume, so always give the group some 3D spread.
Reflection Probes
Light Probes handle diffuse baked light; Reflection Probes handle the shiny part. A reflection probe captures a cube-map "photo" of its surroundings so that glossy, metallic surfaces nearby reflect the actual room instead of only the distant skybox.
Add one with GameObject โธ Light โธ Reflection Probe, size its box to cover an area (a room, a hall), and bake it. Metallic/smooth materials inside that box now show a believable local reflection. Like lights, probes can be Baked (cheap, static) or Realtime (updates live, costs performance) โ bake unless the environment genuinely changes.
๐ก Two probes, two jobs: Light Probes tell a moving object how bright and what colour the light is around it; Reflection Probes tell a shiny surface what the world looks like reflected in it. Most polished scenes use both.
The Bake Pipeline
Put the whole workflow together and it's a short, repeatable sequence:
Static + Contribute GI"] --> B["Set lights to
Baked or Mixed"] B --> C["Open Lighting window
enable Baked GI"] C --> D["Add a Light Probe Group
around playable space"] D --> E["Add Reflection Probes
for glossy areas"] E --> F["Click Generate Lighting"] F --> G["Progressive Lightmapper
traces + writes lightmaps"] G --> H{"Looks right?"} H -- "No: dark movers, seams,
too soft" --> I["Adjust resolution / probes
/ UVs and re-bake"] I --> F H -- "Yes" --> J["Done โ nearly free
lighting at runtime"]
Figure 2: The lightmapping pipeline, from flagging static objects to a finished bake.
Common Bake Problems
- Moving objects are dark โ no Light Probe Group, or the object is outside the probe cloud. Add/extend probes.
- Blocky shadows / seams โ Lightmap Resolution too low, or the mesh has bad lightmap UVs. Raise resolution a little, or enable Generate Lightmap UVs on the model's import settings.
- Bake takes forever โ resolution too high or too many static objects. Drop resolution; use the GPU lightmapper if your hardware supports it.
- Lightmaps are huge in the build โ too many high-res atlases. Lower resolution, reduce Lightmap Size, keep Compress Lightmaps on.
- Light leaks (light bleeding through a wall) โ the wall is too thin for the texel size. Thicken it or raise resolution locally.
โ Pro Tip
Bake at a low resolution while you iterate on layout and light placement โ fast feedback. Only crank the resolution for your final "beauty" bake once the scene is locked. Iterating at high resolution wastes hours.
Hands-on Challenge
๐๏ธ Exercise 1: Bake a lit room and light a mover
Objective: take a scene from "flat" to "baked and believable."
- Build a small room (floor + walls) and mark every piece Static with Contribute GI on.
- Add a Point light, set its Mode to Baked, and give it a warm colour.
- Open Window โธ Rendering โธ Lighting, ensure Baked Global Illumination is on, and click Generate Lighting.
- Drop a Sphere with a Rigidbody in and let it roll through โ it'll be dark.
- Add a Light Probe Group, spread probes through the room's volume, re-bake, and watch the sphere pick up the warm baked tone as it rolls.
๐ก Hint: the sphere is still dark after adding probes
Re-bake after adding the probes (probes are baked too), and make sure the sphere's Mesh Renderer has Light Probes set to Blend Probes, not Off. Also confirm the probes actually surround the sphere's path in 3D, not just a flat line on the floor.
โ Success check
The static walls and floor show soft baked shading and colour bleed, and the rolling sphere is clearly lit โ brighter and warmer near the light, dimmer in the corners โ even though the light is fully Baked.
๐๏ธ Exercise 2: Add a reflection
Give the sphere a metallic, smooth material. Add a Reflection Probe that encloses the room and bake it. Compare the sphere's reflection before and after โ it should shift from reflecting only the distant sky to reflecting the actual walls of your room.
๐ฏ Quick Quiz
Question 1: Which flag must be enabled for an object to be included in a lightmap bake?
Question 2: What is a Light Probe Group for?
Question 3: Your bake is taking forever and the lightmaps are enormous. What's the first knob to turn down?
Summary
๐ Key Takeaways
- Mark unmoving scenery Static with Contribute GI so it takes part in the bake.
- The Lighting window (Scene / Environment / Baked Lightmaps) is where you enable Baked GI, set resolution and size, and press Generate Lighting.
- The Progressive Lightmapper traces light and writes it into lightmap textures that are nearly free at runtime.
- Light Probes carry baked light onto moving objects; place them where lighting changes.
- Reflection Probes give glossy surfaces believable local reflections.
- Iterate at low resolution; save the high-resolution bake for the final pass.
๐ What's Next?
You've been using shaders (the Lit shader) and lighting them. Time to make your own. In Lesson 8.3: Intro to Shader Graph you'll open Unity's visual shader editor, wire nodes into a Master Stack, and drive a material's colour and effects without writing a line of HLSL.
๐บ๏ธ You can bake a scene now
Flag the static world, bake it into lightmaps, probe the movers, reflect the shine. That pipeline gives console-quality lighting at a fraction of the runtime cost.