Lightmapping Troubleshooting Guide

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