5.2.1 Pre compute

The pre-compute stage is divided into a number of steps including packing, clustering, and computing the light transport.

The following figure shows the status of the running tasks in the progress bar at the bottom of Unity.
Figure 5-2 Progress

To illustrate the individual steps, consider the scene in the following figure, consisting of a floor, a wall with a corner and a TV hanging on the wall:
Figure 5-3 Wall and TV scene

Packing

Packing takes the existing UVs or the UVs Unity created for you when you select Generate Lightmap UVs in the Import settings, identifies charts, and packs the charts into the light map used for the real-time lighting.

Charts are groups of triangles that share the same vertices. Enlighten repacks these UVs to ensure that there is no light leaking between charts while also ensuring that the UVs are packed as tightly as possible. You can see the results of the packing in the UV Charts mode and also in the Charting preview, shown in the previous screenshot.
The precompute, run-time memory usage, and the run-time performance of Enlighten all depend on the number of light map pixels. You can use Enlighten to generate simplified UVs that deal with complex geometry more efficiently. Simplified UVs are on by default, but if you carefully crafted your own UVs, you can disable this by ticking Preserve UVs. You can see the results in the UV Charts render mode.
The following figure shows this mode with Preserve UVs enabled.
Figure 5-4 Wall and TV scene with Preserve UVs

The original UV layout and its charts are all shown in a different color. Parts of the TV, the wall, and the skirting board all consist of multiple charts, leading to an overall larger number of charts.
Only enable Preserve UVs if you have carefully authored UVs that you want to preserve in Unity. In most cases it is best to not enable this flag.
If Preserve UVs is disabled and the Auto UV Max Distance set to a small value, such as 0.01 the packing results look like the following figure:
Figure 5-5 Wall and TV scene with Auto UV Max Distance at 0.01

Except for the colors of the visualization, the packing is very similar. It has roughly the same number of charts, but the unwrapping is slightly different.
The Auto UV Max Distance tells Enlighten what details can be omitted from the illumination. Enlighten tries to merge charts by creating a UV layout for the combined charts, but it does not split input charts. The new UV layout is created by projecting the vertices of all charts considered onto an optimal plane in world space. Only charts whose world space vertices are not more than the given distance above the plane are considered for merging.
With the chosen light map resolution, only a few light map pixels are used for the wall and the floor. This is enough to capture the coarse global illumination of the scene. You can expect that the fine details are filled in by screen-space ambient occlusion. The TV and the skirting board on the other hand are so small that they barely require one pixel, but were allocated far more, because they consist of several charts, and charts have a minimum size of 4 pixels by 4 pixels.
The following figure shows the result of increasing the distance value to 0.5:
Figure 5-6 Wall and TV scene with Auto UV Max Distance at 0.5

Enlighten projects the UVs of the TV and the skirting board onto the wall and floor respectively. They therefore do not require any additional pixels in the light map. You can clearly see this in the Charting preview. Using even larger values lead to more details being ignored.
The following figure shows the results of a distance of 2:
Figure 5-7 Wall and TV scene with Auto UV Max Distance at 2

While the light map is even smaller, Enlighten considers the different parts of the wall, including the corner, to be one segment, with pixels spanning the different parts. Similar to Auto UV Max Distance, you can define what charts Enlighten considers for merging based on the angle between triangles. The default value of 89, in degrees, ensures that Enlighten does not merge charts that are set at a right angle to each other in world space.

Clustering and light transport

To model the light transport in a scene, Enlighten splits the scene geometry into clusters.

The clusters are separate from the light map pixels and generated only from the position and orientation of the triangles. Materials or UV coordinates are not used. Unity does not have a visualization for clusters.
The following figure shows the clusters in the demo scene:
Figure 5-8 Wall and TV Clusters

Every cluster receives input lighting from lights placed in the scene, emits light itself, or can both receive and emit light. For every pixel in a light map, and for every light probe, Enlighten casts rays in all directions of its hemisphere or in all directions for probes. It calculates the visibility of the cluster from the pixel or probe. Enlighten assumes that the scene only consists of diffuse surfaces, so that the visibility is directly proportional to the light that the pixel receives from the clusters. The visibility is often called form-factor in computer graphics. When the form-factors have been calculated, they are compressed to reduce memory usage and performance requirements.
The following figure shows a simplified view of this process. The figure shows a pixel X that sees the three clusters A, B and C with visibility values of 0.35, 0.3 and 0.2. At run-time, Enlighten can evaluate the lighting that this pixel receives by evaluating
0.35*A+0.3*B+0.2*C
After the form-factors are calculated, they are compressed to reduce memory and performance costs.
Figure 5-9 Form Factors

The pre-computed data must be updated whenever the geometry is changed, because the clusters depend on the geometry of the scene. Unity can automatically trigger the pre-compute when it is required, or you can turn the continuous build off, and only trigger it when you are finished with the scene changes. You must pre-compute a scene before you can use real-time lighting or bake lights.
Unity exposes the Cluster Resolution setting that controls the size of a cluster in relation to the light map resolution. The default value of 0.5 means that a cluster is twice the size of a light map pixel. There is rarely any reason to change this.
The light transport calculates the form-factors. Enlighten has two important parameters that affect this step:
  • The Irradiance Budget is the number of form-factors that Enlighten stores. Enlighten merges form-factors as much as required to stay within a given budget, but a too small budget produces oversimplified illumination. On the other hand, a larger budget consumes more run-time memory and the run-time solving cost is higher. Normally the default value of 128 is a good choice, but values as low as 64 can also give good results. Increasing this value does not increase the light transport time and therefore also not the pre-compute time.
  • The Irradiance Quality is the number of rays to cast per pixel. Increasing this value results in longer pre-compute times. The default of 8192 normally produces good results, but if you have chosen a high light map resolution, ARM recommends you also increase this value as well, because the indirect light might contain noise. This value does not affect run-time memory or performance.
To speed development, leave this option set to the default or a value that produces reasonable results when developing your game. Increase the value before shipping to get the maximum quality.
Non-ConfidentialPDF file icon PDF versionARM 100140_0201_00_en
Copyright © 2014, 2015 ARM. All rights reserved.