Version: Unity 6.6 Alpha (6000.6)
Language : English
Generate lightmap UVs
Check lightmap UVs

Lightmap packing

Lightmaps are pre-calculated lighting textures that store illumination for static geometry. Unity generates them via a multi-step process that transforms 3D meshThe main graphics primitive of Unity. Meshes make up a large part of your 3D worlds. Unity supports triangulated or Quadrangulated polygon meshes. Nurbs, Nurms, Subdiv surfaces must be converted to polygons. More info
See in Glossary
data into optimized 2D textures. Both the Realtime Global IlluminationA group of techniques that model both direct and indirect lighting to provide realistic lighting results.
See in Glossary
system and the Baked Global Illumination system use lightmaps, and therefore need lightmapA pre-rendered texture that contains the effects of light sources on static objects in the scene. Lightmaps are overlaid on top of scene geometry to create the effect of lighting. More info
See in Glossary
UVs.

Lightmap texture packing in Unity

Unity stores baked lighting in lightmap textures that the renderer can sample efficiently. To improve lighting quality and performance, Unity packs each mesh’s lightmap UV charts into a small set of lightmap textures.

Unity provides the following lightmap packing algorithms:

  • xAtlas: The default packing algorithm. xAtlas automatically packs UV charts according to their shape and orientation rather than their bounding boxes.
  • Unity lightmap packer: The optional Unity packing algorithm.

Packing

Unity repacks real-time lightmap UVs so each chart’s boundary falls on a texel center in all directions, then adds a half-texel margin around each chart’s boundary. This ensures a full texel of margin between charts.

Because the resolution of real-time lightmaps is intentionally low to allow updates at runtime, charts that share texels can bleed. Repacking ensures charts never share texels, avoids bleeding, and allows Unity to efficiently pack charts next to each other.

Real-time lightmap UVs packing
Real-time lightmap UVs packing

Note: This packing technique means the UVs Unity calculates depend on the instance’s scale and lightmap resolution, which is why real-time lightmap UVs are per-Mesh Renderer. Unity optimizes this where possible: Mesh RenderersA mesh component that takes the geometry from the Mesh Filter and renders it at the position defined by the object’s Transform component. More info
See in Glossary
that use the same mesh with the same scale and lightmap resolution share the same UVs.

Example

The following UV atlases demonstrates the difference between xAtlas and the Unity built-in packer.

These UV atlases use the Unity lightmap packer based on bounding boxes. They use two lightmap textures and leave a lot of unused space.
These UV atlases use the Unity lightmap packer based on bounding boxes. They use two lightmap textures and leave a lot of unused space.
This xAtlas UV atlas uses one lightmap texture only and saves space when it packs the UV charts.
This xAtlas UV atlas uses one lightmap texture only and saves space when it packs the UV charts.

Select the Unity lightmap packer

For speed, compatibility, or quality reasons, you can select the traditional Unity packing method based on bounding boxes.

To select the Unity lightmap packer:

  1. Select Window > Rendering > Lighting.
  2. In the SceneA Scene contains the environments and menus of your game. Think of each unique Scene file as a unique level. In each Scene, you place your environments, obstacles, and decorations, essentially designing and building your game in pieces. More info
    See in Glossary
    tab, expand the Lightmapping Settings section.
  3. Select Custom from the Lightmap Packing dropdown.
  4. Set Packing Method to Unity.

Unity applies your packing configuration to subsequent bakes.

Additional resources

Generate lightmap UVs
Check lightmap UVs