This is the documentation for Enlighten.

The lightmap UV pipeline


The precompute produces lightmap UVs for each geometry object that uses lightmaps. The precompute creates a lightmap for each radiosity system which contains a lightmaps for each instance contained by the system.

To quickly produce lightmap UVs so that you can preview the charts, run the lightmap UV generation stage alone. When you launch the precompute, change the argument /t:Precompute to /t:PrecompSys. This is the equivalent of the System Precompute option in GeoRadiosity.

Geometry lightmap UVs

The first stage in the precompute UV pipeline is the Pack Geometry stage. This produces a single lightmap UV set for each geometry object in the scene.

For the meshes within each geometry object that are not detail meshes, for a given lightmap pixel size, the precompute tries to produce a UV layout:

  • requiring the minimum number of lightmap pixels
  • while avoiding significant distortion of the square shape of each lightmap pixel in 3D space

These stage includes the following steps:

  1. Provide input chart UVs: used as a starting point.
  2. Chart identification: split input charts based on surface normal discontinuity.
  3. Chart merging: unwrap each identified chart to 2D and merge adjacent charts to produce simplified UVs.
  4. Chart scaling: Adjust lightmap resolution for each merged chart to match its relative size in 3D space.
  5. Chart packing: Pack final charts into a rectangular lightmap.

The precompute generates lightmap UVs for detail meshes using mesh projection.

Provide input chart UVs

When generating the lightmap UVs for a geometry object, the precompute uses as input the Chart UV attribute of the vertices in each mesh object.

Use this to control the way Enlighten will:

  • split the faces of a mesh into lightmap UV charts,
  • unwrap each chart to 2D lightmap space.

The input chart UV layout does not determine the final lightmap UV layout and unlike a lightmap UV layout:

  • There's no need to pack all the charts tightly into the unit square.
  • It's OK if there is no space, or a lot of space between each chart in the UV layout.
  • It's not necessary to make charts larger or smaller in UV space to control the resolution of the lighting.
  • It's OK if one input chart overlaps another in the UV layout.

To prevent lighting artifacts, make sure the triangles within a single input UV chart do not overlap in UV space.

If you have existing material UVs or lightmap UVs, provide them as input to improve the quality of UVs generated by automatic UV simplification.

Any of the following are valid choices; those that generally produce better results are listed first:

  1. manually authored simplified chart UVs
  2. existing lightmap UVs authored for baked lighting
  3. existing material UVs
  4. omit input UVs (all zero)

Chart merging

Automatic UV simplification minimizes the number of lightmap pixels required by automatically unwrapping and merging charts.

This step does not split the charts produced by the previous chart identification step. For the best results, make sure that chart identification is configured to group charts based on vertex position and normal (the default)

With the mode simplifyUsingUvs, Enlighten will fall back to the input chart UVs if automatic simplification does not produce better results. To force the use of automatically simplified UVs, use the mode simplifyNoUvs.

If the automatic process does not produce good enough results, disable automatic UV simplification to force the precompute to use the input UVs that you provided.

Chart scaling

The precompute uniformly scales each chart in UV space to produce the desired pixel size in 3D space, while preserving the required spacing between charts.

By default, the precompute individually adjusts the scale of each chart in UV space to match its relative size in 3D space. This means the artist need not worry about correctly scaling each input UV chart to produce a consistent lightmap pixel size for all parts of the mesh.

For some meshes, the artist may want different parts of the mesh to have different pixel sizes. For example: large building mesh with more pixels at the bottom than the top.

To preserve the relative scale of each input chart, specify the attribute scaleCharts=false on the mesh element in the geometry object.

Chart packing

The precompute packs all scaled charts in a geometry object into the smallest, squarest possible rectangular lightmap.

Each chart always uses at least 2x2 pixels in the lightmap, and is surrounded by half a lightmap pixel of padding space. 

System lightmap UVs

The final stage in the lightmap UV pipeline is the Pack System stage. This stage outputs lightmap UV information for each instance in a radiosity system.

The precompute reuses the same lightmap UV layout for each instance of the same geometry object. The precompute only applies a scale and translation to pack each instance into the system lightmap.

This enables more efficient rendering, when you share lightmap UVs between instances of the same geometry object.

When an instance object has a transform attribute with a scale factor greater than one, the precompute adjusts the size of lightmap pixels for each instance to match the specified output pixel size. 

  • When the transform does has scale factor equal to one, the size and shape of pixels in world space is the same for each instance.
  • When you apply a scale factor less than one to an instance, its lightmap pixels become smaller than the specified output pixel size.
  • When you apply a scale factor greater than one to an instance, the precompute compensates for this by applying the same scale (rounded to the closest integer) to the instance UV layout.