UDN
Search public documentation

LightMapUnwrapping
Licensees can log in.

Red links require licensee log in.

Interested in the Unreal engine?
Check out the licensing page.

Questions about UDN itself?
Contact the UDN Staff

Unwrapping meshes for light-maps

Document Summary: Light-maps have special constraints on the UV coordinates they use. This document explains those constraints.

Document Changelog: Initial version.

Mirror over the texture's X axis

This affects both light-map textures and vertex light-maps.

Light-maps store lighting for three different directions, and blend between them based on the actual normal per-pixel. The three directions are fixed in tangent-space, so in world-space they will be mirrored the same as the texture coordinates. The directions that are used are only symmetric over the texture's X axis. To ensure that the same directions in world-space are used on both sides of the mirror seam, UV map the mesh so the mirroring seam is as close to vertical as possible.

Using the same world-space directions on both sides of the mirror seam is important because the accuracy of the light-map depends on them. If different directions are used, the light-map will be less accurate on one side of the seam, which can result in a visible seam in the light-map.

The tangent basis is built from the first UV set, so those are the texture coordinates which need the mirroring to be on the texture's X axis.

Split the light-map UVs for the mirrored pieces

The mesh's light-map UVs need to be separated by a few texels at a mirror seam. This is necessary because the texels from the two halves can't be blended together; and if they're close that can occur due to the smoothing filter applied to light-maps, or bilinear texture filtering.

Looking at the wall mesh from Torlan as an example you can see that texture space was saved by mirroring most of the normal map over the x axis

UV1.jpg

The second UVW coordinates used to generate the lightmap information would normally have a clean unique unwrap such as below.

UV2.jpg

To avoid the seam ingame the mirrored half should be selected...

UV3.jpg

and then split where the mirrored section is on the texture...

UV4.jpg

then when the asset is viewed ingame you will not get the seam you would have gotten previously...

UV5.jpg

you will instead get the result you intended and still save texture space.

UV6.jpg

Caveats

When making this modification to eradicate the seams you need to bear in mind that while the resolution of the texture may be 1024-2048, the lightmap will be around 128 pixels square so its important to test your change ingame with a lighting rebuild on that asset at the lightmap resolution you intend to use for that object.

Leaving too small a gap will still leave you with small artifact's on a low lightmap resolution.

Note that any seam in the lightmap texture coordinates will produce visual artifacts, which may be unacceptable in theory and practice; however, proper lightmap UV creation can reduce seam artifacts to a degree that is really only recognized by artists. It is advised to use a ¾ mirroring offset (rather than exactly half); so, in the case of a face, go slightly past the nose.

Bear in mind that the tradeoff is one of improving performance, in terms of the reduction of the cost of assets used in a level, vs. well-disguised visual artifacts.

In general, Vertex light maps are the only way to completely avoid a seam.