This is the documentation for Enlighten.

Sharing lightmap UVs

For efficient rendering of many instances of the same mesh, we recommend to share one set of Enlighten lightmap UVs between many draws.

Enlighten generates one lightmap UV set per geometry object. To generate one set of lightmap UVs for a mesh that is used by two instances, create one geometry object used by both instances.

Enlighten generates a lightmap UV transform for each instance. When you draw an instance with a shared lightmap UV buffer, apply the instance lightmap UV transform to the lightmap UV coordinate in the vertex shader to compute the final UV.

Instance UV transform

The instance lightmap UV transform is a 2D affine transform, which contains only scale and translation. Because there is no rotation, m_LinearTransform[0][1] and m_LinearTransform[1][0] are always zero.

Before you upload the transform to the vertex shader, pack it into a single float4.

	Geo::GeoVector4 packedUvTransform = Geo::GeoVector4(
		uvTransform.m_LinearTransform[0][0],
		uvTransform.m_LinearTransform[1][1],
		uvTransform.m_Translation[0],
		uvTransform.m_Translation[1]
	);

The example below shows how to transform the shared lightmap UV coordinates by the packed instance transform to produce the instance lightmap UVs.

float2 TransformUV(float4 packedUvTransform, float2 uv)
{
	return uv * packedUvTransform.xy + packedUvTransform.zw;
}