4.2.2 Lightmaps and light probes

Runtime lighting calculations are computationally expensive. A popular technique to reduce the computation requirements called lightmapping pre-computes the lighting calculations and bakes them into a texture called a lightmap.

This means you lose the flexibility of a fully dynamically lit environment, but you do get very high quality images without impacting performance.
To bake the resulting lighting in a static lightmap
To see the resulting lightmap:
If the Continuous Baking option is selected Unity bakes the lightmap and updates the scene in the Editor in seconds.
A quick way to check that the lightmap has set up correctly is to run the game in the Editor and disable the light. If the lighting is still there, the lightmap has been created correctly and it is in use.
The following figure shows an intensity lightmap in the Lighting tab.
Figure 4-8 The intensity lightmap

The following figure shows the editor displaying lighting from a green light at the end of a cave. This lighting is generated with a static lightmap.
Figure 4-9 Adding a light to bake a static lightmap

The following figure shows the result of the static lightmap in the Ice Cave demo.
Figure 4-10 Lightmapped cave

Setting up lightmapping

To prepare an object for lightmapping you must have:

  • A model in your scene with lightmap UVs.
  • The model must be marked as lightmap static.
  • There must be a light in range of the model.
  • The Baking type of the light must be set to Baked.


Only the static objects in your scene are lightmapped. They are not likely to be perfect, so experiment to see what works best for your game.
Objects that are not marked as static are not placed in the lightmap. Selecting a renderer provides you with a number of settings and enables you to set whether its lightmap is static or not.
Open the Lighting window from the main menu of the editor window and select Window and Lightmapping. There are three buttons:
  • Object.
  • Scene.
  • Lightmaps.
The following figure shows lightmap options:
Figure 4-11 Lightmap options

Clicking the Object button enables you to change settings related to lightmapping on the object you have selected in the hierarchy. This enables you to modify the object settings that impact the lightmapping process. Select a light, and you can change a number of options:
  • Baked Only enables the light at baking time and disables it at runtime.
  • Baked If Baked GI is selected, the light is baked.
  • Realtime The light works for both pre-computed real-time GI and without GI.
  • Realtime Only disables the light at baking time and enables it at runtime.
  • Mixed The light is baked, but it is still present at runtime to give direct lighting to non-static objects.
Setting the majority of lights to Baked ensures the number of calculations at runtime is relatively low.
The Scene tab contains settings that apply to the whole scene. You can enable and disable the Pre-computed Realtime GI and Baked GI features in this tab.
In the Environment Lighting section, there are a number of options that allow you to define several factors influencing the environment lighting, such as the Skybox, the type of Ambient Source, and the Ambient Intensity:
  • The Reflection Bounces option is the most important from the performance point of view. Reflection Bounces defines the number of inter-reflections between reflective objects, that is, the number of bake times for the probe that sees the objects. This option can have a large negative impact on performance if the reflection probes are updated at runtime. Only set the number of bounces higher than one if the reflective objects shall be clearly visible in the probes.
  • In the Precomputed Realtime GI tab the CPU Usage option defines the amount of processor time that is spent evaluating GI at runtime. A higher value for CPU Usage results in faster reactions from the lighting, but might affect frame rate. The impact on the performance is lower in multiprocessor systems.
  • The Baked GI tab contains an option where you can set the lightmap texture to be compressed. Compressing lightmap textures requires less storage space and less bandwidth at runtime but the compression process can add artifacts to the texture.
  • In the General GI tab, be careful with the Directional Mode option. If you cannot use deferred lighting with dual lightmaps, another technique is to use directional lightmaps. These enable you to use normal mapping and specular lighting without real-time lights. Use directional lightmaps if normal mapping must be preserved but dual lightmaps are not available. This is typically the case on mobile devices. When Directional Mode is set to Directional an additional lightmap is created to store the dominant direction of incoming light. As a result this mode requires about twice as much storage space.
  • In Directional Specular mode, additional data is stored for specular reflection and normal maps. In this case the storage requirements increase four times.
  • The Lightmaps tab enables you to set and locate the lightmap asset file used for the scene. To access the Lightmap Snapshot box the Continuous Baking option must be unchecked.
The following figure shows lightmaps in the Lighting tab:
Figure 4-12 Lightmaps in the Lighting tab

Use directional lightmaps

If you cannot use deferred lighting with dual lightmaps, another technique is to use directional lightmaps. These enable you to use normal mapping and specular lighting without real-time lights.

Use directional lightmaps if normal mapping must be preserved, but dual lightmaps are not available. This is typically the case on mobile devices.


This technique requires more video memory because it computes a second set of lightmaps to store directional information.

Use light probes for dynamic objects in your game

Light probes enable you to add some dynamic lighting to lightmapped scenes.

The following figure shows light probe settings:
Figure 4-13 Light probe settings

Light probes take a sample, or probe, of the lighting in an area. If the probes form a volume, or cell, the lighting is interpolated between these probes depending on their position within the cell.
The following figure shows light probes:
Figure 4-14 Light probes

The more probes there are, the more accurate the lighting is. You do not typically require many light probes because there is interpolation between probes. You require more light probes in areas where there are large changes in light color or intensity.
The lighting at any position can then be approximated by interpolating between the samples taken by the nearest probes.
Take care placing the light probes and mark the meshes you want to be influenced by them with the Use Light Probes option.
The following figure shows multiple light probes:
Figure 4-15 Multiple light probes

Non-ConfidentialPDF file icon PDF versionARM 100140_0201_00_en
Copyright © 2014, 2015 ARM. All rights reserved.