Lightmapping Troubleshooting Guide

Introduction
I developed this guide in order to help developers get the most out of Baked Global Illumination (GI) in the Unity Editor. Here, I unpack some of the most common lightmapping problems and their solutions, supported by images and links to pages in the Unity Manual.

You can read the announcement blog post by clicking this link.

Want to learn more about lightmapping in Unity? Check out the Global Illumination Learning Resources thread.

Table of Contents

42 Likes

Chapter 1: No baked global illumination in the scene


Figure 1. Cornell Box scene rendered with no global illumination (left) and with baked global illumination (right).

1.1 Why does this happen?
If some prerequisites are not met, Progressive Lightmapper might fail to generate lighting in your scene. These include, but are not limited to:

  • No objects are marked as GI Contributors
  • No baked lights in the scene
  • Shader issues

1.2 How to fix it?
1.2.1 Mark GameObjects as GI Contributors


Figure 2. Contribute GI settings under the Mesh Renderer component.

Mark objects you want to lightmap as GI Contributors. To do so follow these steps:

  • Select your GameObject.
  • Navigate to the Mesh Renderer component.
  • Unfold the Lighting header.
  • Check the Contribute to Global Illumination checkbox.

Doing so will enable the Receive Global Illumination parameter underneath. It contains two options:

  • Lightmaps. Meant for static lightmapped objects. GameObject will receive and contribute GI to lightmaps.
  • Light Probes. Meant for small props, and objects not fit for lightmapping. GameObject will receive GI from light probes and will contribute GI to the surrounding lightmaps.

1.2.2 Inspect scene lights
Only mixed and baked lights can contribute to baked GI. Select lights in your scene, and make sure that in the Light component, Mode is set to either Mixed or Baked.

Other properties which are worth checking are:

  • Color. Dark colors will have low or no GI contribution. Choose bright colors for lights and use the Intensity property to boost or dim them.
  • Intensity. The higher the intensity, the brighter the light. Ensure that your lights are bright enough for meaningful GI contribution.
  • Indirect Multiplier. This property controls the intensity of the indirect bounce. Make sure that it is not set to zero. Otherwise, the light will have no contribution to GI at all. Note that setting this value above one will make the lighting in your scene non-compliant with the PBR standard.

1.2.3 Inspect the Lighting Setting Asset
In the Lighting window, accessible via Window > Rendering > Lighting, make sure that the Lighting Settings Asset field is not blank. If there is no asset assigned, click on the New Lighting Settings button. This will create and assign an asset, unlocking the properties in the window for editing.

Once you have done that, check for the following issues:

  • Ensure that you have ticked the Baked Global Illumination checkbox. This enables baked GI computations. This checkbox will also expose the Lighting Mode dropdown.
  • Check that the Max Bounces value is not set to zero. The higher this value, the more the light will bounce around the environment.
  • Check that the Indirect Intensity slider is not set to zero. Setting this slider to zero will diminish all indirect lighting in the scene.

1.2.4 Inspect shaders and materials
Custom shaders could be the reason why GI computation has failed. For debug purposes, use built-in shaders that come with the Unity editor. Those are:

  • Standard shader. Available in the built-in render pipeline.
  • Lit shader. Available in the Universal Render Pipeline.
  • Lit shader. Available in the High-Definition Render Pipeline.

If Unity generates lighting after switching to one of the shaders outlined above, the problem might be with custom shaders. In such cases, make sure that your surface shaders contain the LIGHTMAP_ON shader keyword.

Check out the meta pass page on how to further customize the baked GI output using shaders.

1.2.5 Other potential fixes
If the above-mentioned steps did not solve the problem, please try the following:

  • Make sure that the lights are not placed inside scene geometry.
  • Enable Mixed Lighting toggle in the Universal Render Pipeline Asset.
  • Select a different lightmapping backend in the Lighting window. If lighting fails to bake when using the Progressive GPU, but succeeds when baking with the Progressive CPU, this might be a result of a hardware or driver problem.
  • Update the GPU drivers. Please refer to the GPU manufacturer’s page for the correct drivers for your system. For Linux machines, please check the Linux driver setup section in this forum thread .
  • Ensure that your GPU meets the minimum requirements. Please refer to this forum thread for details.
  • Clear the GI Cache. To clear it, navigate to Preferences > GI Cache and click on the Clean Cache button. Keep in mind that this will delete all lighting data present in the scene, requiring you to regenerate lighting.
4 Likes

Chapter 2: Objects are missing lighting


Figure 3. Cornell Box scene with a non-lightmapped metallic sphere and a statue. Both objects are black when no light probes or reflection probes are present (left). Diffuse statue is visible when lit by light probes (center). Both the reflective sphere and the statue are visible after placing light probes and reflection probes (right).

2.1 Why does this happen?
Certain objects appearing as unlit or out of place may indicate a problem with the scene setup. It often reproduces when dynamic objects have no light probes to sample the lighting from. Glossy metallic materials can appear as black when no local reflection probes are present.

2.2 How to fix it?
2.2.1 Place light probes
Dynamic objects, or GI contributors receiving GI from light probes need light probes to sample indirect lighting data. If none are present, objects will fall back to sampling the Ambient Probe (light and reflection probe which is always present in the scene).

Set up a Light Probe network in the scene, adding more probes in areas of high importance. Make sure that there are enough light probes to encompass all affected objects. Generate lighting again to see the effect.

2.2.2 Place reflection probes
Reflective metallic objects might still render as black, even after placing a dense network of light probes. To shade such objects, you would need to place a Reflection Probe which encompasses the affected object. Generate the lighting again or re-bake the probe in the Reflection Probe Component by clicking the Bake button.

If you observe black areas in the reflections, try increasing the Bounces count. This will increase the number of bounces, thus creating reflections within reflections. You can access this property in Lighting > Environment > Environment Lighting.

2.2.3 Inspect Mesh Renderer settings


Figure 4. Light Probes and Reflection Probes properties need to be set to Blend Probes (or anything else than Off).

If performing the above-mentioned steps does not solve the issue, inspect the Mesh Renderer component of the affected object. Under the Probes section, make sure that the Light Probes and Reflection Properties are not set to Off.

2.2.4 Adjust material color values
Pure black materials will absorb all direct and indirect light. This is physically correct behavior. In real life, no naturally occurring material is completely black. One of the darkest natural materials, coal, measures approximately at 50,50,50 on an RGB luminosity scale.

Adjust your material color values to follow the physically based shading standards. In the built-in render pipeline, you can use Validate Albedo scene view draw mode to determine whether albedo values are compliant with the Physically Based Rendering (PBR) standard. Use the Rendering Debugger in URP and HDRP to do the same.

2.2.5 Check scene setup
If you are working with multiple scenes, make sure that the scene containing lighting is set as the Active Scene. By default, Unity sets the first loaded scene as the active scene, which might have a detrimental effect in the standalone player builds.

2 Likes

Chapter 3: Emissive materials not rendering


Figure 5. The plane in the ceiling and the sphere both have emissive materials applied to them (left). Bloom enabled as a post processing effect to give an impression of a glowing material (center). Emissive plane and sphere both marked as GI contributors influencing lighting in the scene (right).

3.1 Why does this happen?
There are two types of issues related to emissive material rendering:

  • Emissive materials do not appear as “glowing”. This indicates a post-processing issue.
  • Emissive materials not contributing to global illumination. This indicates an issue with object or material setup.

3.2 How to fix it?
3.2.1 Enable bloom in the post processing stack
To create an impression of a glowing material, enable Bloom in the post processing stack of your choice. Refer to Built-in RP, URP, and HDRP documentation on how to do this.

3.2.2 Check material properties


Figure 6. Material inspector in the Built-in render pipeline. We highlighted Emission properties in blue.

If you intend on using emissive objects for lightmapping, make sure that:

  • You have marked the GameObject in question as a GI Contributor. Due to the self-illuminating nature of emissive objects, you can set their Receive Global Illumination property to Light Probes. This will save space in the lightmap atlas.
  • Global Illumination property is set to Baked in the Material Inspector. This property is available under the Emission input. Refer to Built-in RP, URP, and HDRP documentation for more details.

3.2.3 Inspect lighting settings
In the Lighting window, make sure that the Indirect Intensity property is not set to zero. Setting it to zero will disable all indirect lighting, including baked contribution from baked emissive objects.

3 Likes

Chapter 4: Flat normal maps


Figure 7. Non-directional lightmaps with a baked light (left). Directional lightmaps with a baked light (right). Non-directional lightmaps lack the directionality of incoming light, which provides a good representation of relief when using normal maps.

4.1 Why does this happen?
When baking in non-directional mode, Unity will not create a separate texture to hold directionality information. This will result in objects looking flat after baking.

It is worth noting that low frequency normal maps are hard to capture using directionality textures. Such textures will appear flat when generating lighting using fully baked lights.

4.2 How to fix it?
4.2.1 Switch to Directional mode


Figure 8. Directionality mode dropdown in the Lighting settings window.

In the Lighting window, set the Directional Mode property to Directional. This mode will generate a secondary texture which will store dominant light direction. Normal maps will have a good representation of relief, but will lack specular response.

4.2.2 Use mixed lights


Figure 9. Directional lightmaps illuminated by a baked spotlight (left). Directional lightmaps illuminated by a mixed spotlight (right). Notice the improved contrast in the normal maps in the scene lit by the mixed light.

Mixed lights provide realtime specular and normal response. The Progressive Lightmapper bakes indirect lighting into a lightmap. This combination ensures the highest quality material response when using baked lighting.

If your project allows for it, switch the light Mode to Mixed in the Light component. Note that mixed lights have the same performance cost as realtime lights. Depending on the Lighting Mode used, mixed lights will cast realtime shadows, but not baked soft shadows.

4.2.3 Use light probes
Probe-lit GameObjects will often have a better material response than those lit by baked lights. If your art direction allows for it, set their Receive Global Illumination property to Light Probes in the Mesh Renderer component. Note that you can also use Light Probe Proxy Volume to add a spatial gradient to probe-lit objects.

3 Likes

Chapter 5: Missing specular response


Figure 10. A simple scene containing several baked point lights before a lightmap bake (left). Same scene after baking lightmaps (right). Notice that specular highlights are missing after baking.

5.1 Why does this happen?
One of the inherent limitations of baked lights is that they do not provide realtime specular response to materials. This means that glossy materials will lack specular highlights after generating lighting.

5.2 How to fix it?
5.2.1 Use mixed lights
Unlike baked lights, mixed lights provide realtime direct specular response to materials. If specular highlights are important in your scene, switch the light Mode to Mixed in the Light component.

5.2.2 Use emissive proxies


Figure 11. Same scene but with emissive proxies captured by the reflection probe (left). An alternative perspective showcasing the placement of said proxies (right).

It is possible to imitate specular response from lights by using emissive objects. To do so, follow these steps:

  • Place a reflection probe in your scene.
  • Right-click in the Hierarchy panel and select 3D Object > Sphere.
  • Select the newly created object and set its Static Editor Flag to Reflection Probe Static.
  • In the Project panel, create a new material by right-clicking and selecting Create > Material.
  • Select the newly created material and enable the Emission checkbox. Set the Global Illumination property to None.
  • Drag and drop the material onto the sphere to assign it.
  • Place the sphere in the same position as your light.
  • Generate lighting.

After following the above-mentioned steps, you should be able to see the emissive objects captured in the reflection probe cubemap. You can hide those objects after baking or set up a Culling Mask in the Camera component.

3 Likes

Chapter 6: Lights flicker or disappear


Figure 12. Pixel Light Count set to 0 (left). Pixel Light Count set to 9 (right). Notice that the realtime shadows and specular highlights are missing completely in the image on the left.

6.1 Why does this happen?
When using the forward rendering path, Unity converts pixel lights to more performant vertex lights. It happens when the number of pixel lights exceeds a certain value. This can result in flickering or disappearing lights when navigating the scene.

This limitation affects Built-in and Universal render pipelines only – HDRP is not affected.

6.2 How to fix it?
6.2.1 Adjust pixel light count property


Figure 13. Project Settings window in the Built-in render pipeline (left). URP asset (right). We highlighted properties which increase the pixel light limit.

It is possible to increase the number of pixel lights Unity renders before converting pixel lights to vertex lights. Here is how to do this:

  • In the Built-in render pipeline, navigate to Project Settings > Quality > Rendering and adjust the Pixel Light Count property.
  • In URP, select the Render Pipeline Asset, and navigate to Lighting > Additional Lights. Make sure that the dropdown is set to Per Pixel and adjust the Per Object Limit property.

Keep in mind that increasing the above-mentioned values will result in extra draw calls.

6.2.2 Adjust Render Mode property


Figure 14. Light component in URP.

For lights of high importance, set the Render Mode dropdown in the Light component to Important. This will reduce the probability of Unity converting said light to a vertex light.

When Render Mode is set to Auto, Unity will check the light’s intensity and its relative distance from the camera before converting it.

Lights which have Render Mode set to Not Important will always revert to vertex lights.

6.2.3 Switch rendering paths
If you need many mixed or realtime lights in the scene, consider switching to a deferred rendering path. Here is how to do this:

  • In the Built-in render pipeline, navigate to Project Settings > Graphics. Under Tier Settings, uncheck the Use Defaults checkbox for the tier of your choosing. Set the Rendering Path dropdown to Deferred.
  • In URP, select the Render Pipeline Asset. Under the Rendering header, set the Rendering Path to Deferred.

6.2.4 Switch to baked lights
The easiest and most performant way to mitigate pixel light limitations is by switching to baked lights. To do so, set the Mode dropdown in the Light component to Baked.

3 Likes

Chapter 7: Mixed lights render as baked


Figure 15. A simple scene containing nine mixed lights baked in Shadowmask mode. Notice that some spheres are unlit and appear as dark (left). Light Overlap debug view highlights overlapping lights in red (center). As shown in the Shadowmask debug view, lightmapper discards overlapping lights, and does not include them in the shadow mask texture (right).

7.1 Why does this happen?
When using Shadowmask lighting mode, only four mixed lights can overlap. Lights exceeding this limit will become baked lights.

In Subtractive lighting mode, all lights – except for directional lights – will not cast realtime shadows. This is an inherent limitation of this lighting mode.

7.2 How to fix it?
7.2.1 Change light placement and radius
To verify that light overlap is the issue, switch to Light Overlap scene view draw mode after generating lighting. This scene view draw mode will highlight overlapping lights in red.

Move the affected lights so that they no longer overlap. Otherwise, adjust the Range or Spot Angle parameters in the Light component. Generate lighting again after making the changes.

7.2.2 Switch to a different lighting mode
Each lighting mode comes with its own advantages and limitations. If your project will be lit using a single directional light, then Subtractive lighting mode might be a better choice than Shadowmask. Please consult the Unity manual page on lighting modes to make the best decision for your project.

2 Likes

Chapter 8: Unexpected environment lighting


Figure 16. Expected result (left) versus the actual result in the standalone player build (right). This example uses realtime lighting. Notice that in the image on the right, shadows have a bluish tint to them. This is due to the SkyManager updating the ambient probe to match the default skybox color. This may or may not be a desired effect.

8.1 Why does this happen?
In the 2021.1 release, we introduced a change that allows Unity to update the default skybox and ambient probes automatically. This ensures that the realtime environment lighting remains accurate without having to rely on baked lighting.

By default, this change might introduce ambient lighting to projects which either rely on custom environment shaders or need no ambient lighting at all.

We are working on making this functionality more flexible in the future releases.

8.2 How to fix it?
8.2.1 Set environment color to black
Setting the environment color to black disables SkyManager updates. Here is how to do this:

  • In the Built-in render pipeline and URP, navigate to Lighting > Environment > Environment Lighting. Set the Source to Color and change it to black. Or, set the Skybox Intensity value to zero.
  • In HDRP, add the Visual Environment override to the Volume component. Set the Sky Type property to None.

8.2.2 Uncheck the Recalculate Environment Lighting toggle


Figure 17. Toggle which disables SkyManager updates in the editor and in the standalone player builds.

Navigate to Lighting > Workflow Settings and uncheck the Recalculate Environment Lighting toggle. Doing so will disable SkyManager updates both in the editor and the player. Please note that this is a global setting and will affect all scenes in your project.

8.2.3 Uncheck the Auto Generate toggle
Navigate to Window > Rendering > Lighting and uncheck the Auto Generate toggle. Remember to bake lighting by clicking on the Generate Lighting button.
Auto Generate is meant for iterating on scene lighting. Having it always enabled is not recommended, and can lead to unexpected results.

4 Likes

Chapter 9: Lightmap UV artifacts


Figure 18. Lightmapped objects exhibiting severe artifacts due to missing lightmap UVs (left). Same objects with correctly authored lightmap UVs (right).

9.1 Why does this happen?
Unlike regular texture UVs, lightmap UVs have different requirements:

  • It cannot contain any overlaps.
  • It must have enough padding between UV shells.
  • It should have minimal area and angle distortion.
  • It should be uniformly scaled.
  • It must be within the [0,1] UV space, and not exceed it.

If lightmap UVs violate one or several of the points outlined above, the affected object will exhibit artifacts post-bake. They might appear as distortions over the surface of an object or as darkening around edges.

9.2 How to fix it
Note: to make the process of debugging easier, consider using UV Overlap and Baked Lightmap scene view draw modes.

For more information, please refer to these pages in the Unity Documentation website:

9.2.1 Generate lightmap UVs in Unity


Figure 19. Lightmap UVs settings in the Mesh Importer window. This allows users to generate lightmap UVs automatically within the editor.

Often, automatic lightmap UVs should be enough for lightmapping. Follow these steps to generate lightmap UVs in the editor:

  • Select the model in your Project view. Unity opens the Model Import Settings in the Inspector.
  • In the Model Import Settings, navigate to the Model tab, and then the Geometry section.
  • Tick the Generate Lightmap UVs checkbox. The Lightmap UVs settings section appears below the Generate Lightmap UVs checkbox.
  • Optional: Configure the settings in the Lightmap UVs settings section. See Settings for more information.
  • Click the Apply button. Unity generates lightmap UVs into the Mesh.uv2 channel.

In the 2020.1 release, we introduced Auto Pack Margin feature when generating lightmap UVs in Unity.

9.2.2 Custom lightmap UVs
Complex objects are good candidates for manually authored lightmap UVs. Please refer to your preferred DCC program documentation on how to use UV authoring tools.

Note that you must place custom lightmap UVs in the second (UV1) channel.

9.2.3 Increase lightmap resolution
When working with lightmaps, use the lowest resolution possible that still achieves good looking results. In some cases, increasing lightmap resolution might be the simplest solution. Keep in mind that an increase in lightmap resolution will result in higher memory use and longer bake times.

3 Likes

Chapter 10: Lightmap UV seams


Figure 20. Lightmap UV split visible across the hand after baking (left). Unity fixes seams after enabling the Stitch Seams option and baking again (right).

10.1 Why does this happen?
By default, GPUs cannot blend color values between separate UV shells. Without the extra post processing step, this limitation can cause visible seams to appear in a lightmap. Aggressive filtering and low lightmap resolution can exacerbate this problem by bleeding texel color values into neighboring UV shells.

10.2 How to fix it
Disclaimer: fixing lightmap seams in a single object can be trivial. It is more difficult to address this problem when working with modular meshes. This is a common issue that most lightmapping backends face, and it is a hard problem to solve.

10.2.1 Enable Stitch Seams option
Stitch Seams option is available in the Mesh Renderer component, under the Lightmapping header. By enabling it, Unity will attempt to fix seams by blending color values between UV shells that share a stitchable common edge in the model.

Note that this option only works with single GameObjects. Multiple GameObjects are not supported.

10.2.2 Combine meshes in a DCC tool


Figure 21. Cornell Box scene assembled using modular meshes with visible seams after lightmap baking (left). Meshes combined in a DCC tool prior to exporting with no lightmap seams visible (right). You can achieve the result on the right by disabling filtering and baking with high sample counts.

The easiest way to mitigate seams is to combine meshes in a 3D modeling package. Make sure to weld overlapping vertices before exporting. Or, you can weld vertices in in the Model Import Settings window. Skipping this step might impede automatic lightmap unwrapping in Unity.

10.2.3 Combine meshes via an API
Mesh.CombineMeshes method combines meshes into one, achieving the same result as merging them in a DCC package.

10.2.4 Combine meshes using ProBuilder
When working with ProBuilder meshes it is possible to merge multiple objects by using the Merge Objects option.

You can make this option available for regular meshes by converting them into ProBuilder meshes using the ProBuilderize option.

10.2.5 Disable filtering and denoising
By disabling filtering, it is possible to avoid blurring and dilation issues described earlier. The main drawback of this approach is long bake times, as you would need to increase the number of samples to achieve clean results.

10.2.6 Increase lightmap padding
If disabling filtering does not solve the issue, try increasing Lightmap Padding value. When working with modular meshes, each mesh has its own UV atlas. Lightmap Padding property allows you to change the distance between UV atlases – but not between UV shells within the atlas - to prevent leaking.

10.2.7 Use light probes
Light probes are often used to provide indirect illumination for dynamic objects. Consider utilizing light probes for difficult to lightmap objects.

It is worth mentioning that probe-lit objects receive lighting information from a single probe. It can be detrimental when illuminating large objects. Light Probe Proxy Volume (LPPV) component can mitigate this problem, by creating a grid of light probes within a bounding volume. As a result, probe-lit objects that make use of LPPVs have a spatial gradient improving their look.

Adaptive probe volumes allow for per-pixel lighting and streamlined placement when compared to light probe groups, and LPPVs.

10.2.8 Hide seams using meshes or textures
If the art direction allows for it, try using trim meshes to hide seams between objects. This is a commonly used technique in game development.

3 Likes

Chapter 11: Blurry lightmaps


Figure 22. Cornell Box scene baked at 8 texels per unit resolution (left). Same scene baked at 32 texels per unit resolution (right). Notice the increased shadow fidelity in the statue, and the lack of light leaking in the tall box.

11.1 Why does this happen?
To ensure high fidelity output, Unity needs a high resolution lightmap to capture lighting information. Too few texels and the result will be blurry.

Also, lightmap texels must be uniform, square in shape. Non-uniformly scaled lightmap UVs will appear stretched post-bake.

11.2 How to fix it?
11.2.1 Adjust lightmap resolution
There are two ways to adjust lightmap resolution:

  • Globally. Use the Lightmap Resolution property in the Lighting window to adjust lightmap resolution for all objects in the scene.
  • Per-object. Adjust the Scale In Lightmap parameter found in the Mesh Renderer component. This parameter is a multiplier of the Lightmap Resolution property found in the Lighting window.

Note that a two times increase in lightmap resolution will result in four times increase in baking times. High resolution lightmaps will also lead to higher memory usage.

Keep a low lightmap resolution for:

  • Surfaces that receive uniform lighting
  • Surfaces that receive indirect lighting only
  • Small objects
  • Surfaces that are not visible to the player

Reserve high lightmap resolution for:

  • Areas of high importance
  • Surfaces which receive baked direct lighting and shadows

11.2.2 Adjust Max Lightmap Size property
Max Lightmap Size will be the limiting factor to the final lightmap resolution. This is especially true for large objects, such as terrains. Increase Max Lightmap Size property in the Lighting window if:

  • Objects start to exceed maximum space in the lightmap atlas
  • The number of low resolution lightmaps after baking is high, even after increasing lightmap resolution

11.2.3 Maintain uniform lightmap UV scale


Figure 23. Lightmap texels stretched horizontally resulting in distorted output (left). Uniformly scaled lightmap texels (right). Both lightmaps have the same 80 texels per unit resolution.

Lightmap texels should remain in a uniform scale. This will prevent lightmap distortions. To ensure this, keep in mind the following:

  • When authoring custom lightmap UVs, do not scale UV shells in one axis only. If you need to scale UV shells, do so uniformly, across all axes.
  • When scaling UV shells, scale an entire atlas. Avoid scaling single shells unless it is necessary.
  • Same logic applies to GameObjects in the editor. Try to keep them uniformly scaled. Scaling objects in one axis will stretch lightmap UVs as well.

Use Baked Lightmap scene view draw mode to inspect lightmap uniformity. Remember to enable the Show Lightmap Resolution checkbox to see lightmap texels.

3 Likes

Chapter 12: Lightmap aliasing


Figure 24. Baked shadows with lightmap super-sampling disabled (left). Same scene with 4x super-sampling (right).

12.1 Why does this happen?
Aliasing is a visual artifact which appears when lightmap resolution is too low. It manifests itself as a stair-stepping effect around edges. It is common when using baked direct lighting in high contrast areas.

12.2 How to fix it?
12.2.1 Tweak the Anti-aliasing Samples property


Figure 25. Lightmap Parameters Asset with the super-sampling property highlighted.

You can find the Anti-aliasing Samples property in the Lightmap Parameters Asset. Anti-aliasing attempts to fix aliasing artifacts by super-sampling texels. More samples will result in smoother results. Available options are:

  • Off. Set the value to any integer in the 1 to 3 range.
  • 2x super-sampling. Set the value to any integer in the 4 to 8 range. This is the default value.
  • 4x super-sampling. Set the value to any integer in the 9 to 256 range.

Higher super-sampling values will result in higher memory consumption while baking and slower bake times. It has no negative impact on memory consumption post-bake.

12.2.2 Use Baked Shadow Angle


Figure 26. Baked shadows with lightmap super-sampling disabled (left). Same scene with the Baked Shadow Angle property set to 0.5 for the Directional Light (right).

Baked Shadow Angle property adjusts the amount of shadow scattering for baked lights. Adjust this property to taste for added realism. This also has an added benefit of smoothing out jaggies in lightmaps. This property is available for most lights in the Light component.

Keep in mind that high Baked Shadow Angle only affects fully Baked lights. It has no effect on Mixed, and Realtime lights. To get smooth results, you would need to increase the number of Direct Samples used for baking.

12.2.3 Use Gaussian filtering


Figure 27. Baked shadows with lightmap super-sampling disabled (left). Same scene with the Gaussian filter radius set to 1 texel (right).

You can access the Gaussian filter in the Lighting window by setting the Filtering dropdown to Advanced. Adjust the Direct Filter radius slider to blur aliased edges.

Note: in Unity 2022.2 and 2023.1 releases we have increased Gaussian filter precision to 0.1 texel radius for finer control.

4 Likes

Chapter 13: Direct, indirect, and environment noise


Figure 28. All sample counts are set to 8 (left). All sample counts are set to 2048 (right).

13.1 Why does this happen?
Progressive Lightmapper is a Monte Carlo path tracer. To achieve clean results, lightmapper needs to spawn many rays from each lightmap texel. Insufficient ray counts will lead to noisy lightmaps.

13.2 How to fix it?
Note: to make the process of debugging easier, in the Lighting window, set the Filtering property to None.

Increasing the number of samples will reduce lightmap noise. It will increase bake times in a linear fashion.

There are three types of sample counts: direct, indirect, and environment.

13.2.1 Increase direct samples


Figure 29. Scene lit only by direct light. Direct samples are set to 8 (left). Direct samples are set to 2048 (right).

Direct samples control the number of rays, which the lightmapper shoots towards light sources.

Increase Direct Samples if:

  • Objects lit by area lights produce noisy soft shadows.
  • Baked lights with a modified Baked Shadow Angle value produce noisy results.

13.2.2 Increase indirect samples


Figure 30. Scene lit only by the indirect bounce light. Indirect samples are set to 8 (left). Indirect samples are set to 2048 (right).

Indirect samples control the number of paths, which the lightmapper shoots towards the GI contributors in the scene. Once they intersect geometry, texels spawn rays towards:

  • Environment, which makes it an indirect environment sample.
  • A light source, which makes it an indirect lighting sample.

Paths can bounce off surfaces. There are a few ways Unity can end a path:

  • Once it reaches the Max Bounces value.
  • If it does not intersect any geometry.
  • By the Russian roulette algorithm.

Increase Indirect Samples if:

  • Indirectly lit areas are noisy.
  • Objects using emissive materials produce a lot of noise.

13.2.3 Increase environment samples


Figure 31. Scene lit only by environment lighting. Environment samples are set to 8 (left). Environment samples are set to 2048 (right).

Environment samples control the number of rays, which the lightmapper shoots towards the sky/environment.

Increase Environment Samples if:

  • Baked environment/HDRI produces noisy results.
  • Note that you would need to disable all lights in the scene to verify this.

13.2.4 Use denoising and filtering
Achieving pristine lightmaps without using filtering would need tens of thousands of samples. Unity can apply a post-processing step to remove noise by using filtering or machine learning denoisers. To enable filtering, navigate to the Lighting window (Window > Rendering > Lighting) and select the Filtering property. There are three options:

  • None. Disables filtering and denoising.
  • Auto. Attempts to select the best filtering and denoising option based on current system configuration.
  • Advanced. Allows users to fine-tune filtering and denoising properties.

Here are the available filters:

  • Gaussian. Applies a bilateral filter (blur) to the lightmap. This may smooth-out noise, at the expense of visual fidelity. Increase radius parameters to increase filtering strength. High values can lead to leaking artifacts.
  • A-Trous. Edge-aware filter which attempts to remove noise, while maintaining edge definition. Works well with high sample counts and in conjunction with denoising. Does not work well with noisy HDR lightmaps.

Here are the available machine learning denoisers:

  • Open Image Denoise (OIDN). Machine learning denoiser from Intel. Vendor agnostic. Works on Windows, macOS, and Linux platforms.
  • Optix. Machine learning denoiser from Nvidia. Works only with Nvidia GPUs. Supports Windows only.
  • RadeonPro. Machine learning denoiser from AMD. Vendor agnostic. Works on Windows and Linux.

For best results, experiment with different denoiser and filtering combinations.

3 Likes

Chapter 14: Fireflies


Figure 32. Fireflies caused by a bright light source placed close to scene geometry. Even at 4K indirect samples the noise is visible (left). Baking with 16K indirect samples and Open Image Denoiser enabled removes the noise.

14.1 Why does this happen?
Small, high luminosity areas in the lightmap cause fireflies to appear. Such areas are easy to miss when spawning rays from texels. When rays intersect those high intensity areas, they skew the average luminosity estimate. This results in speckled noise often referred to as “fireflies”.

14.2 How to fix it?
Note: we are planning on addressing this issue for punctual lights in the future with the splat clamping feature. The importance sampling feature already addresses this issue for HDRIs.

14.2.1 Increase sample counts
This is a brute force method. To achieve acceptable results, you would need to use 4K indirect samples, or more, in conjunction with filtering and denoising.

14.2.2 Enable importance sampling


Figure 33. Fireflies caused by the high frequency HDRI (left). Same scene after enabling the Importance Sampling toggle (center). High frequency cubemap used to illuminate the scene (right).

Figure 34. Enabling Importance Sampling can introduce noise when using low frequency HDRIs. Importance Sampling disabled (left). Importance Sampling enabled (center). Low frequency cubemaps used to illuminate the scene (right).

Importance sampling analyzes the environment map and finds areas of high intensity in it.

Enable importance sampling if:

  • You are using a high frequency HDRI image for environment lighting. An example of this would be an HDRI with a bright sunspot in the horizon.

Disable importance sampling if:

  • You are using a low frequency HDRI image for environment lighting. An example of this would be an overcast HDRI or a solid color skybox.

Enabling importance sampling when using low frequency HDRIs can result in increased noise levels.

14.2.3 Enable filtering and denoising
Fireflies are challenging to remove even when using ML denoisers in conjunction with filtering. To get clean results, you would still need to use high sample counts.

14.2.4 Avoid small baked emissive objects
When using emissive materials, consider setting the Global Illumination property to None in the Material Inspector. The object will keep its self-illuminating appearance, but it will not contribute to global illumination. This may reduce noise.

14.2.5 Move baked lights away from static geometry
URP and HDRP use inverse square falloff for lights by default. In the Built-in render pipeline, you can achieve the same effect by using custom falloff scripts. The unfortunate side effect being that such lights might lead to increased noise levels when placed very close to static geometry. Ensure that there is enough distance between the static geometry and the lights in the scene.

3 Likes

Chapter 15: Invalid texel artifacts


Figure 35. Scene containing a one-sided curtain mesh which causes invalid texel artifacts to appear after baking (left). Texel Validity scene view mode highlights invalid texels in red (right). Notice how saturated invalid texels are around the curtain area.

15.1 Why does this happen?
Sometimes, invalid texels can be the cause of blocky artifacts in a lightmap.

Unity can mark Lightmap texels as invalid under the following circumstances:

  • When a given texel has not received any illumination via direct, indirect, or environment samples.
  • Rays originating from a texel have intersected back-facing surfaces.

Lightmap filtering and denoising can make this issue worse by spreading invalid texels to neighboring texels. That is why it is important to address this issue early on without relying on post processing.

15.2 How to fix it?
Note: to make the process of debugging easier, consider using Texel Validity scene view draw mode.

15.2.1 Adjust mesh normals


Figure 36. Cube in the center has all its vertex normals facing outwards, resulting in a seamless and correctly shaded mesh. Blue polygons in the cube on the left are flipped. Orange polygons in the cube on the right are flipped. Cubes on the left and right will both exhibit invalid texel artifacts after baking, whereas the one in the center will not.

Vertex normal direction determines which side of the polygon appears as the front (visible) side. Flipping the direction of the normal will render the face invisible unless you are using double-sided shaders. Always ensure that the polygons, which you want to be visible, have their normals pointing outwards.

Most 3D modeling applications generate correct normals automatically. There are times when you would need to adjust mesh normals manually. To do so, please refer to 3ds Max, Maya, Blender, or other 3D modeling package documentation of your choice.

15.2.2 Avoid open faces
In some cases, adjusting normals might not be enough. For more complex meshes, make sure that they are watertight before exporting:

  • Cap all open faces.
  • Weld all overlapping vertices.
  • Avoid line and point geometry.
  • Avoid floating geometry unless your use case requires it.

Ignoring the above-stated suggestions might result in invalid texel artifacts when baking. In 3ds Max, try using xView to help identify mesh issues. Refer to documentation articles on how to do this in other 3D modeling applications.

15.2.3 Enable the Double-Sided Global Illumination material property


Figure 37. We have enabled Double Sided Global Illumination for the curtain mesh which before caused invalid texels to appear (left). Texel Validity view no longer shows any invalid texels in red around the curtains (right). Notice that not only the artifacts are gone, but the light also bounces off curtains.


Figure 38. Material inspector in different render pipelines. Built-in render pipeline (left), URP (center), and HDRP (right). We have highlighted the properties related to Double Sided Global Illumination in blue.

Foliage, decals, and other thin one-sided meshes often do not benefit from the steps outlined above. In such cases, the easiest way to fix texel validity artifacts is by enabling Double Sided Global Illumination material property. Once enabled, the lightmapper treats back-facing polygons as front-facing polygons during lightmap baking.

To make use of double-sided GI, follow these steps:

  • In the Built-in render pipeline, enable Double Sided Global Illumination checkbox in the Material Inspector. Same steps apply to custom ShaderGraph materials as well.
  • In URP, set the Render Face dropdown to Both. You can find this property under the Surface category in the Lit Shader.
  • In HDRP, two properties located under the Surface category in the Lit Shader control the double-sided GI behavior:
  • Double-Sided. Enable this checkbox to disable backface culling. This also enables double-sided GI.
  • Double-Sided GI. This dropdown contains three options: Auto, On, and Off. When Auto is selected, double-sided GI is enabled if Double-Sided property is also enabled. On and Off options allow to override double-sided GI behavior without making material appear double-sided.
  • You can also control double-sided GI material property via the API.

15.2.4 Why not always enable Double-Sided Global Illumination property?


Figure 39. Double Sided Global Illumination disabled (left) and enabled (right). Notice dark artifacts where the meshes intersect in the image on the right. In such cases, disable Double Sided Global Illumination to achieve correct output.

Lightmapper marks texels as invalid when they receive no illumination or intersect backfaces. This allows the dilation filter to push lighting data from valid surrounding texels into partially covered texels. Doing so helps to remove dark artifacts at geometry junctions.

Enabling double sided GI by default for all materials, would result in a darkening effect where meshes intersect or overlap.

Please use this setting at your own discretion where it makes sense.

15.2.5 Adjust the Backface Tolerance property
You can access the Backface Tolerance property via the Lightmap Parameters Asset. Create a new lightmap parameters asset and assign it via the Mesh Renderer component, under the Lightmapping section.

This property controls the percentage of rays that must hit front-facing geometry to consider the texel valid:

  • Increasing the value increases the likelihood the lightmapper marks a texel as invalid when it sees backfaces.
  • Lowering this value will reduce the number of invalidated texels.

Note that low values might result in a loss of occlusion and/or bounce lighting, thus changing the look of the scene.

15.2.6 Move meshes closer to the world origin
Note: we are planning on addressing this issue in the future by implementing 64-bit floating-point precision support for the unified lightmapping backend.

Limitations imposed by the 32-bit floating-point precision format can be the cause of invalid texels. It happens when placing lightmapped meshes far away from the world origin (0,0,0), or if they have a massive scale. This issue is not limited to lightmapped meshes; objects and animations will lose precision the farther away they are from world origin.

To resolve this issue, move meshes closer to the 0,0,0 world coordinate. Or, try adjusting the Push off value in the Lightmap Parameters Asset.

For more information, please refer to the excellent article on floating-point arithmetic by Alan Zucconi.

4 Likes

Chapter 16: Denoising artifacts


Figure 41. Scene lit by an emissive object placed outside the door. Severe artifacts are visible when all sample counts are set to 32 with the Open Image Denoiser enabled (left). The image is cleaner with all sample counts set to 2K and with the Open Image Denoiser enabled (right).

16.1 Why does this happen?
Machine learning denoisers are effective at removing noise, but can still struggle under certain circumstances:

  • In particularly noisy scenes, especially when there is a lot of speckle noise (fireflies).
  • With thin geometry and at edge intersections due to dilation.
  • When using high intensity light sources which need HDR lightmaps.
  • When there is not enough training data to denoise the scene.

Artifacts often appear as smears, smudges, or as ringing around edges. Sometimes, denoisers can produce black lightmaps, or fail to denoise the scene, thus leaving the noise intact.

16.2 How to fix it?
16.2.1 Increase sample count


Figure 42. RMSE graph from Enter the Room project. This graph measures how different filtering and denoiser methods perform when compared against the ground truth image. Both Optix and OIDN graphs show good results after the 256-sample mark. Note that the results will differ across projects.

The easiest way to improve denoising performance is to increase the number of samples. In most cases, indirect noise will be the largest culprit for poor denoising performance.

Most denoisers perform well at 256 samples and higher. For more information on the subject, please watch the following GDC 2019 presentation: Intel Open Image Denoise in Unity: Open Source Denoising for Lightmaps (Presented by Unity and Intel)

16.2.2 Try a different denoiser
Some denoisers might perform better under certain circumstances. To choose a different denoiser, set the Filtering property to Advanced. This will allow you to specify which denoiser to use for direct, indirect, and ambient occlusion buffers.

16.2.3 Use Gaussian or A-Trous filters
If denoising does not yield the result you are looking for, you can try using Gaussian or A-Trous filters instead. To specify which filter you want to use, set the Filtering property to Advanced. You can use filters in conjunction with machine learning denoisers.

4 Likes

Chapter 17: Filtering artifacts


Figure 43. Scene filtered using Gaussian filter at a 1 texel radius. With all samples set to 32, the final lightmap exhibits splotches (left). Baking with all samples set to 2K and with Gaussian filtering enabled yields better results (right).

Figure 44. Scene filtered using A-Trous filter. With all samples set to 32, A-Trous edge preservation algorithm cannot distinguish between noise and edges, and thus completely fails (left). After increasing all samples to 2K, A-Trous filter yields decent results, with less blurring when compared to Gaussian (right).

17.1 Why does this happen?
Gaussian and A-Trous filters both differ in terms of functionality, and the artifacts they can introduce tend to be different as well.

Artifacts associated with aggressive Gaussian filter settings:

  • Light and/or shadows leaking through geometry.
  • Blurry results.
  • Splotchy lightmaps.

Artifacts associated with the A-Trous filter:

  • Speckled noise at low sample count.
  • Failure to denoise HDR lightmaps (noise interpreted as edges).

17.2 How to fix it?
17.2.1 Increase sample count
As was the case with denoisers, increasing sample counts will improve filtering performance as well.

17.2.2 Use a machine learning denoiser
Denoisers are more effective at removing noise than filters and have less bias. It is also possible to use filtering in conjunction with denoising. A-Trous works well with machine learning denoisers. The Gaussian filter works well too, albeit at a low radius.

17.2.3 Tweak filtering settings
Unlike denoisers, both Gaussian and A-Trous filters allow you to tweak the strength of the filtering applied. You can do this by adjusting radius and sigma values. If your scene suffers from lightmap leaking artifacts, or over blurring, try reducing the Gaussian filter radius value. This will reduce the amount of bi-lateral blurring and will prevent texel smearing.

2 Likes

Chapter 18: Lightmap leaking


Figure 45. Lightmap leaking introduced by aggressive Gaussian filtering settings and poor object placement (left). Open Image Denoiser mitigates leaks, but not entirely (center). Adjusting the Y-coordinate of the affected props so that they do not intersect scene geometry fixes the issue entirely (right).

18.1 Why does this happen?
Lightmap leaks occur when a single lightmap texel occupies lit and shadowed areas at the same time. This causes the baked light to “leak” into surrounding texels, causing a noticeable difference in lighting. It is common to see this artifact in dimly lit indoor areas, with a bright light outdoors.

18.2 How to fix it?
18.2.1 Adjust lightmap UVs and resolution
Increasing Lightmap Resolution can help with texel coverage and thus reduce light leaking.

If increasing the resolution is not possible, you would need to change lightmap UVs in a DCC tool. Split the lightmap UV chart at the seam between light and dark areas. This will prevent lighting from bleeding into surrounding texels. Make sure that there is enough padding between charts to minimize leaks.

18.2.2 Adjust filtering settings
Aggressive Gaussian filter settings can introduce light leaks. Please refer to the filtering artifacts section on how to fix this.

18.2.3 Adjust scene geometry
In many instances, light leaking might not be a byproduct of aggressive filtering, but rather of suboptimal object placement. Make sure that your objects do not intersect or stick out through the scene geometry. For interior scenes, avoid using one-sided wall meshes if possible; opt for extruded meshes instead.

3 Likes

Chapter 19: Compression artifacts


Figure 46. Banding artifacts introduced by low quality compression on Android platform (left). You can fix banding artifacts by using high quality compression (right).

19.1 Why does this happen?
Color banding and blocky artifacts are often associated with low quality texture compression. Unity attempts to automatically select the best compression format for the target platform. Due to compatibility concerns, texture formats intended for mobile platforms are often more affected by compression artifacts.

19.2 How to fix it?
19.2.1 Change Lightmap Encoding setting


Figure 47. Project Settings window. We have highlighted the Lightmap Encoding dropdown in blue. You can find the HDR Cubemap Encoding setting underneath.

Lightmap Encoding setting determines how Unity encodes High Dynamic Range (HDR) lightmaps. You can access it in Project Settings > Player > Other Settings. Higher quality tiers provide better results. You need to adjust this setting for each platform.

19.2.2 Change HDR Cubemap Encoding setting
In the 2022.1 release, we introduced a HDR Cubemap Encoding setting in the Project Settings window. This property is almost identical to the Lightmap Encoding setting, but it controls the encoding of the cubemaps instead of lightmaps.

If reflective objects in your scene exhibit artifacts, switch to a higher quality preset for the affected target platform.

19.2.3 Change Lightmap Compression property


Figure 48. Lightmap Compression property in the Lighting window.

Lightmap Encoding influences how Unity encodes lightmaps. Lightmap Compression dropdown in the Lighting window determines the actual compression quality. There are four options: None, Low Quality, Normal Quality, High Quality. Higher quality presets will result in less compression artifacts post-bake.

19.2.4 Override texture format manually


Figure 49. Texture Importer window allows users to manually override texture compression format.

It is possible to override lightmap compression format manually via the Texture Importer. To do this, follow these steps:

  • In the Project window, navigate to the folder which contains the lightmap textures.
  • Select one of the lightmap textures.
  • In the Inspector window, scroll all the way to the bottom, and click on one of the tabs representing each installed platform.
  • Enable the checkbox to override the texture format for the platform of your choice.
  • Select the desired format and click Apply.

It is worth noting that your customizations will be overwritten every time you generate lighting. Follow the above-mentioned steps again after baking.

3 Likes