shown in other instead.
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.
- 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.
- 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.
For all surfaces intended to be lightmapped, the Lightmaps Parameters are needed to be adjusted:
- Check Enabled to enable the feature.
- Enable Bake, if you intend to use the integrated lightmapper.
- 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.
- Enable the Lightmap buffer: Rendering -> Buffers -> Lightmap.
- Open the Bake Lighting window.
- 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.
- 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.
- 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.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.
- Upon completion, generated lightmaps will be saved in the bake_lighting/lightmaps folder and applied to the corresponding surfaces.
- 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:
- Activate Bake option for LOD0, while disabling this option for all other LODs that will share its lightmap.
- Bake lightmap for LOD0.
- Copy the path to LOD0’s lightmap and paste it to the Texture field for other LODs.