UnigineEditor
Interface Overview
Assets Workflow
Settings and Preferences
Working With Projects
Adjusting Node Parameters
Setting Up Materials
Setting Up Properties
Landscape Tool
Using Editor Tools for Specific Tasks
Extending Editor Functionality
Programming
Fundamentals
Setting Up Development Environment
Usage Examples
UnigineScript
C++
C#
UUSL (Unified UNIGINE Shader Language)
File Formats
Rebuilding the Engine Tools
GUI
Double Precision Coordinates
API
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Objects-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes

Lightmapping

Lightmapping is a static global illumination technique using precalculated textures that store brightness and reflected color of lit surfaces. By using lightmapping you can avoid heavy computations of lighting in primarily static scenes.

Lightmapping is the most efficient solution enabling to achieve realistic diffuse lighting and keep the high performance. It is capable of giving high-detailed global illumination combined with simulation of many light bounces. The number of bounces is the key aspect of creating realistic lighting in bright scenes. When you use lightmapping it doesn’t matter how many rays, bounces, or light sources are there, as everything is calculated once and then baked in textures.

UNIGINE provides an integrated GPU-accelerated Lightmapper tool available in the Bake Lighting window.

Current limitations:

  • Lightmapping is available only for surfaces of Static Mesh objects.
  • Only Non-Directional lightmaps are supported at the moment (normal maps are not taken into account).
  • Only global illumination is baked, direct lighting is to be provided by light sources.
Notice
For dynamic objects it is recommended to use voxel probes.

See Also#

  • Lightmaps baking is also available via code by using the BakeLighting Class.

Preparing The Content#

Proper and non-overlapping UV-coordinates of scenery are required for correct lightmapping. In the case your assets do not have ones, automatic UV unwrapping on import is provided.

In the Import Settings for FBX, CAD models and UNIGINE .mesh assets, select the UV Channel and Target Resolution to be used for lightmaps and, if needed, chack UV channels to unwrap according to the selected Packing Quality. Traditionally, the 0 UV channel is used for texturing and the 1 channel is for lightmapping.

The Lightmap Target Resolution parameter has the direct influence on the baking time and the final quality.

Notice
Unwrapping thin polygon meshes intended to be used with double-sided materials applied, such as pieces of paper, banners or fabrics, may lead to visual artifacts when lightmapping. It is recommended to consider re-modeling such meshes by adding polygons for the other side of the model.

For all surfaces intended to be lightmapped, the Lightmaps Parameters are needed to be adjusted:

  1. Check Enabled to enable the feature.
  2. Enable Bake, if you intend to use the integrated lightmapper.
  3. Also, you can specify the lightmap Texture generated in third-party software.

For a surface to contribute to static GI baking, it must have the Cast Global Illumination option enabled.

For selective group-based shading when baking lightmaps, adjust the Viewport Masks. A surface will be visible for the lightmapper only if its Viewport Mask matches the Baking Viewport Masks of Bake Lighting window.

Finally, set up light sources in the scene:

  • For light sources that should contribute to lightmapping, select the Static mode. Dynamic lights will be ignored. Only indirect lighting from lights is baked into lightmaps, so light sources are to be kept enabled to provide direct lighting and specular highlights.
  • For emissive surfaces (having Emission state in the material parameters enabled) also enable the Emission Bake GI option. Both direct and indirect (bounced) lighting from emissive materials is baked into lightmaps.
  • Lighting from voxel and environment probes is not considered.

Baking#

  1. Enable the Lightmap buffer: Rendering -> Buffers -> Lightmap.
  2. Open the Bake Lighting window.
  3. Enable Bake Lightmaps for Surfaces. Adjust the baking settings:
    • Set up the Baking Viewport Masks.
    • Select the desired baking Quality. The Draft option provides the shortest baking time and is suitable for development iterations, while the Ultra quality engages the biggest possible number of light rays to be simulated and the best sampling resolution.
    • Adjust the Far Clipping Distance for simulated light rays.
  4. Adjust the Common settings:
    • Select the number of light ray bounces. Higher values will result in a brighter lighting since each surface receives more photons.
    • Set the number of samples calculated per frame. This parameter is available for adjustment during baking process.
  5. Start baking process by clicking Bake All and wait for it to finish. Live preview is available. Several iterations (one per bounce) will be simulated for each affected surface.
    Notice
    You can stop the process at any moment by using the Stop button and you will be prompted to keep the achieved result or restore the previous textures.
  6. Upon completion, generated lightmaps will be saved in the bake_lighting/lightmaps folder and applied to the corresponding surfaces.
  7. In the materials settings of lightmapped surfaces, consider enabling the Lightmap Cubic Filtering option for better quality.

You can check the result by selecting the Baked Lightmap mode in the Rendering Debug.

If you are not satisfied with results on certain objects, you can select surfaces and/or nodes and perform partial re-bake using different settings by clicking Bake Selected.

Levels of Detail#

You can bake a separate lightmap for each LOD. Moreover, you can save space by sharing already baked lightmaps between different LODs (works for LODs having the same UV maps). Here is how you do that:

  1. Activate Bake option for LOD0, while disabling this option for all other LODs that will share its lightmap.
  2. Bake lightmap for LOD0.
  3. Copy the path to LOD0’s lightmap and paste it to the Texture field for other LODs.

Last update: 2020-10-13