Version: 2017.1
Getting started with UIElements
Scripted Importers

Progressive Lightmapper

What

The progressive lightmapper is a path tracing based lightmapper backend that provides baked lightmaps and light probes with progressive updates in the Editor.

The progressive lightmapper goes through a short prepare step (geometry and instance updates, G-buffer and chart mask generation) and starts producing the output very quickly. New lightmaps and light probes are shown as soon as a new intermediate result is ready. This allows for a very fast iteration workflow.

Why

The old Enlighten-based lightmapper for baked lightmaps relied on precomputed realtime GI to generate indirect lighting. That was both an advantage, as just changing the lighting could produce new lightmaps fairly quickly, and a disadvantage, as it imposed all the UV layout limitations even for users only interested in baking. The UV requirements in the progressive lightmapper are the usual for baked lightmapping: non-overlapping UVs with small area and angle errors, and sensible padding between the charts.

The new lightmapper starts producing the output immediately and progressively refines it over time for a much improved lighting workflow - this means an interactive lighting workflow. Additionally, baking times are much more predictable.

See an in-depth video showing the interactive workflow here.

Moreover the new technique bakes global illumination at the lightmap resolution - for each texel individually - without upsampling schemes or relying on any irradiance caches or other global data structures. This makes it robust and allows you to bake selected portions of lightmaps, which means that iteration speed can be improved greatly.

Setup

Newly created scenes have the progressive lightmapper enabled by default. Existing scenes will stick to Enlighten until you choose the “Progressive (experimental)” Bake Backend.

Settings

  • Bake Backend - “Enlighten” is the old baking backend and “Progressive (experimental)” is the new one.
  • Stationary Lighting Mode: Specifies which scene lighting mode will be used for all stationary lights in the scene. Options are Baked Indirect, Distance Shadowmask, Shadowmask and Subtractive. Currently light modes are not supported, please be sure to set ‘Baked Indirect’ and do not use ‘Stationary’ lights. The support will come soon.
  • Lightmap Resolution - The amount of texels per world unit. Keep in mind that increasing this value by two, increases the amount of texels to be calculated by four. Please check the “Occupied texels” count in the stats below.
  • Lightmap Padding - The padding (in texels) between different instances in the atlas. In order to change padding between UV charts inside an instance please adjust ‘Pack Margin’ on the mesh importer in the Advanced settings under ‘Generate Lightmap UVs’.
  • Compress Lightmaps - Intermediate lightmaps are not compressed, but the final ones do respect the compression setting.
  • Samples - The amount of samples (paths) shot from each texel. For some scenes, especially outdoor scenes, 100 samples may be enough. For indoor scenes with emissive geometry more will be needed.
  • Bounces - Number of indirect bounces to do when tracing paths. For most scenes two bounces is enough. For some indoor scenarios more may be necessary.
  • Filtering - Configure the post-processing of lightmaps to limit noise. It can be set to None, Auto or Advanced. The Advanced option offers three additional parameters for manual configuration. In Auto mode the default values from the Advanced mode are used.
    • Direct Radius: The radius of the Gauss filter in texels for direct light in the lightmap. A higher radius will increase the blur strength.
    • Indirect Radius: The radius of the Gauss filter in texels for indirect light in the lightmap. A higher radius will increase the blur strength.
    • AO Radius: The radius of the Gauss filter in texels for ambient occlusion in the lightmap. A higher radius will increase the blur strength.
  • Prioritize View - When enabled texels currently visible in scene view camera frustum will be prioritized. When those are done, the lightmapper will continue on all the out-of-view texels.

Stats

The panel below the ‘Auto Generate’ and ‘Generate Lighting’ options shows the amount of lightmaps that were created, how many are in view (converged / not converged) and out of view (converged / not converged) and the bake performance.

Lightmap parameters

In addition to the Baked GI settings in the Lighting window, there are new parameters in the Lightmap Parameters asset that can be configured. These are Anti-aliasing Samples, Pushoff and Backface Tolerance. Default lightmap parameters can be set for the scene in General GI > Default Parameters or set per renderer.

  • Anti-aliasing Samples - The number of times to supersample a texel to reduce aliasing. Samples [1;3] disables supersampling, samples [4;8] give 2x supersampling, and samples [9;256] give 4x supersampling. (This is a bit weird UX-wise, we’ll improve on that front.) This mostly affects the amount of memory used for the positions and normals buffers (2x uses four times the amount of memory, 4x uses 16 times the amount of memory).
  • Pushoff - The amount to push off ray origins away from geometry along the normal for ray tracing, in modelling units. It is applied to all baked lightmaps, so it affects direct light, indirect light and ambient occlusion. It is useful for getting rid of unwanted occlusion/shadowing.
  • Backface Tolerance - The percentage of rays shot from an output texel that must hit front faces to be considered usable. Allows a texel to be invalidated if too many of the rays cast from it hit backfaces (the texel is inside some geometry). In that case artefacts are avoided by cloning valid values from surrounding texels. For example, if backface tolerance is 0.0, the texel is rejected only if it sees nothing but backfaces. If it is 1.0, the ray origin is rejected if it has even one ray that hits a backface. In the Baked Texel Validity scene view mode one case see valid (green) and invalid (red) texels. If you have a single sided mesh in your scene, you may want to disable this feature by setting it to zero. A two-sided flag will later be added in the editor to address this.

The rest is the default Unity 5 workflow. Mark your objects as static and set some light inputs (lights, environment lighting or emissive materials on static objects) as baked.

In “Auto” mode the lightmaps and light probes will be calculated automatically. If you have “Auto” disabled you will need to press the “Build” button for the bake to start.

Other Features

Force stop: Allows for stopping the bake at an arbitrary point in time, before the requested amount of samples has actually been done. It works when the lighting is built manually. With the 100,000 max sample count and the ability to disable view prioritization, one can leave the machine baking and just stop whenever the results look pleasing.

Invalid texels: Texels are marked as invalid based on the Backface Tolerance parameter (LightmapParameters > General GI) and invalid texels are filled from the valid neighbours. The dilation process that takes care of that does more iterations once the lightmap has converged than when it’s still improving.

Supersampling: The lighting quality is influenced by the supersampling amount. Control it using the ‘Anti-aliasing Samples’ property (Lightmap Parameters > Baked GI, see the Lightmap Parameters section above).

Example project

This project is set up with the settings needed for the progressive lightmapper. It is a version of the Tanks! project also available on the Asset Store. It bakes in less than 5 minutes and has 11 1024x1024 lightmaps. Watch a video showing the interactive workflow in this project.


  • 2017–07–04 Page published with no editorial review

  • 2017–07–04 New feature in Unity 5.6 (Experimental)

Getting started with UIElements
Scripted Importers