Premium
Configuring Lightmaps
Tutorial
Beginner
15 Mins
Overview
Summary
Lightmapping is the process of pre-calculating the brightness of surfaces in the Scene. It stores the information it calculates in a chart or lightmap for later use. Lightmaps allow you to add global illumination, shadows, and ambient lighting at a relatively low computational cost. In this tutorial, we’ll get to know the lightmapping settings.
Topics we'll cover
Language
English
Recommended Unity Versions
2018.1 and Above
Tutorial
Configuring Lightmaps
1.
Configuring Lightmaps
Lightmapping is the process of pre-calculating the brightness of surfaces in the Scene. It stores the information it calculates in a chart or lightmap for later use. Lightmaps allow you to add global illumination, shadows, and ambient lighting at a relatively low computational cost.

2.
More Information on Lightmaps
The Unity Engine uses the Progressive Lightmapper system, which bakes lightmaps for your scene based on how your scene is set up. It takes into account all the meshes, materials, textures, and lights within the scene as it does its pass. When a lightmap is generated, GameObjects automatically use them as they are an integral part of the Unity rendering engine.

3.
Getting to Know Lightmap Settings
Let’s get your Scene and lightmap set up:
From the Windows dropdown select Lighting > Settings from the toolbar. This will open the Lighting Window. (Figure 01)
  • Collapse all the windows and leave only Lightmapper Settings expanded.
  • Change the Lightmapper setting to Enlighten.

4.
Enlighten Settings
For now, we’re only concerned about the Lightmap Settings in the Light Setting Window.
  • Lightmapper: Use this to specify which internal lighting calculation to use when calculating the lightmaps in a scene. The options are Progressive and Enlighten.
  • Indirect Resolution: This option is only available when Realtime Global Illumination is enabled. Use this to specify the number of texels per unit to use for the indirect lighting calculation. The higher the number, the higher the quality, but this also increases the bake time. This setting refers to both Height and Width of the Lightmap.
  • Lightmap Resolution: Use this to specify the number of texels per unit to use for lightmaps. The higher the number, the higher the quality, but this also increases the bake time. This setting refers to both Height and Width of the lightmap.
  • Lightmap Padding: Use this to specify the separation between the different shapes in the baked lightmap.
  • Lightmap Size: The size of the full lightmap texture.
  • Compress Lightmaps: Toggle this to compress your lightmap. Compressed lightmaps use less disk space, but the compression process can introduce unwanted visual artifacting into the texture.
  • Ambient Occlusion: Toggle this to adjust the additional settings of the ambient occlusion in your lightmap (Figure 02). The additional settings are: Max Distance, which controls how far the lighting system will cast rays. Indirect Contribution controls the brightness of the indirect light as seen in the final lightmap. Finally, Direct Contribution controls the brightness of the direct light.
  • Final Gather: Toggle this if you want Unity to calculate the final light bounce in the GI calculation at the same resolution as the bake lightmap. This option will improve the visual quality of the lightmap but it also increases the bake time.
  • Directional Mode: This option allows you to store information about the dominant light at each point on a GameObject. It has two settings: Directional Unity will generate a second lightmap to store the dominant direction of incoming light. This allows for diffuse normal-mapped materials to work with the GI. Non-Directional Unity does not generate a second lightmap, but stores it within the same lightmap that is generated.
  • Indirect Intensity: This controls the brightness of the indirect light that Unity stores in its Realtime and Baked lightmaps.
  • Albedo Boost: This controls the amount of light Unity bounces between surfaces by intensifying the Albedo Materials.
  • Lightmap Parameters: This allows you to select a few predefined settings for the Lightmap. The options you can select to set the default settings of the lightmap from Very Low, Low, Medium, and High defaults. This setting will also allow you to save your own custom settings into a new default option.

5.
Progressive Settings
Now that we’ve covered the settings for the Enlighten mode, let’s take a look at the Progressive mode.
  • In the Light Settings window, change the Lightmapper option to Progressive. (Figure 03)
Progressive mode settings differ a bit from Enlighten mode. We’ll cover those differences here.
  • Prioritize View: Enable this to cause the Lightmapper to apply changes to the texels that are currently visible in the Scene View before applying changes to the out-of-view texels.
  • Direct Samples: This controls the number of samples shot from each texel. It ultimately controls the number of samples that Progressive Lightmapper uses for direct lighting calculations.
  • Indirect Samples: This controls the number of samples shot from each texel. It ultimately controls the number of the samples that Progressive Lightmapper uses for indirect lighting calculations.
  • Bounces: This controls the number of indirect bounces to do when tracing paths. Usually for most scenes a value of 2 is enough.

6.
Setting up for Baking
No matter if you choose Progressive or Enlightened Lightmapper settings, you will understand how to properly set up your project for lightmap baking.
  • First, make sure any Mesh you want to apply a lightmap to has proper UVs for lightmapping. The easiest way to do this is to open the Mesh Import Settings and enable the Generate Lightmap UVs setting.
  • Within the Light Settings window, under the Lightmapping Settings, select the Lightmapper setting you wish to use: Progressive or Enlightened.
  • Next, you want to set the resolution of the lightmaps. Adjust the Lightmap Resolution value to your preferred resolution.
  • Now you want to ensure the GameObjects/Terrain you wish to lightmap are able to receive the lightmap. Select the GameObjects you wish to include and make sure Lightmap Static is checked in the Mesh Renderer Component (Figure 04). This tells Unity that the GameObjects with this turned on don’t move or change. Unity will then add to them to the lightmap.
  • Finally, you might want to adjust the settings of your Lights in the Light Explorer. To access this, go to the Windows dropdown and select Lights > Light Explorer. (Figure 05)
  • Here, you can adjust which lights will be visible, their colors, intensities and so forth. This is for any fine-tuning you might need to make before baking the lightmap.

7.
Baking the Lightmap
Now, with the set up done and the quick overview of the myriad settings, it’s time to bake our lightmap.
  • If the Light Settings window is not open, reopen it by opening the Windows dropdown and selecting Light > Settings.
  • Ensure that you are within the Object Maps tab within the Lighting Window.
  • At the bottom of the Scene tab of the window, click Generate Lighting or toggle the Auto Generate tick box next to it. (Figure 06)
  • Once that’s done, a Progress bar will appear in the Unity Editor status bar in the bottom-right corner. (Figure 07)
  • When the baking is complete, you will be able to see all the baked lightmaps in the Global Maps and Object Maps tabs of the Lighting Window.
Once the Lightmaps have been generated, Unity will update the Scene view automatically so you can see the results and make any necessary adjustments.
Lightmaps provide a great benefit from scenes with many static light sources as it precomputes all the lighting and shading information and removes the cost from the runtime of the project. It can have potentially large savings with large complicated scenes with plenty of light sources.