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.
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:
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.
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.
The following UV atlases demonstrates the difference between xAtlas and the Unity built-in 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:
Unity applies your packing configuration to subsequent bakes.