Lightmap Generation Tool
This tool is used to bake lighting of the scene into light maps. It can be also used to create a set of pre-baked LightProbs that can simulate dynamic lighting for moving objects.
Workflow to Create Light Maps
- Make sure that all surfaces for which light maps will be baked have a unique mapping (no tiling, mirroring or overlaps) in the second UV channel. This check can be done in the MeshViewer. If necessary, reexport models from your 3D editor into a mesh.
- Setup dynamic lighting in the scene.
- Go to the Materials settings -> States tab and set Ambient render pass to LightMap for all materials that are planned to be illuminated with light maps.
- Create empty lightmap textures of the desired size. It can be of any format, but must have power-of-two size. Specify the path to textures in the materials: Textures tab -> Lightmap.
- Select target objects for which a lightmap will be created (by clicking on the nodes in the scene while holding SHIFT or in the Nodes settings).
- Open Tools -> Illumination tab:
- Adjust parameters (see detailed description below).
- Click Create LightMaps button (the tool will bake lighting according to UV mapping into all lightmap textures specified in materials with lightmap state set).
- Check the result (use Enable LightMaps and Disable LightMaps buttons to quickly compare the original and the baked lighting result).
- Adjust parameters and re-bake light maps, if needed (use Update LightMaps button for faster re-baking).
- Select another set of objects and repeat the procedure (if different settings are needed).
- Disable the light sources if unnecessary and save the scene.
It is also possible to illuminate moving objects (like characters) with pre-baked lighting using probe light sources, as if they are lit in real time. LightProbs can be automatically added to the scene:
- Open Tools -> Illumination tab.
- Adjust LightProb settings.
- Click Create LightProbs button. A set of LightProb sources will be added into the node tree.
- Save the scene when done.
Options
The tool generates a 3D grid of LightProbs with a given step for the selected object. They calculate both direct and indirect term of lighting and automatically bake the result into a lightmap. During this process, LightProbs are created and removed from the scene basing on the specified LightProb and baking settings.
A set of LightProbs can also be added into the scene afterwards (via Create LightProbs button) for lighting moving objects with pre-baked lighting.
LightProb parameters
Step | Distance between LightProbs in units when they are generated in a 3D grid around the selected object. |
---|---|
Near clipping | The distance to the near clipping plane of LightProbs in units. By high values light sources will not light objects close in front of them. |
Far clipping | Far clipping plane distance in units. It controls how far objects that are lit can be. |
Bound mesh | An optional mesh that bounds the lightmap calculation space. |
Bound expand | Scale factor along X, Y and Z axis for a bounding box of the selected objects. It expands the space to perform lighting calculations (can't be lower than 1.0).
|
Merge threshold | Similarity threshold (according to light color and intensity) to merge neighboring LightProbs into a single one with with bigger radius and reduce the number of created light sources. This parameter is not important when baking a light map, though less LightProbs means faster calculation. However, it makes a big difference in case when creating LightProbs for illumination in the game. By the value of 0, the merging is skipped leaving all LightProbs in place. |
Baking parameters
Direct scale | Scale of direct illumination term. This is the light which comes directly from a light source:
|
---|---|
Indirect scale | Scale of indirect illumination term. This is the light that once fallen onto a surface, whether reflective or not, is reflected from it and slightly colors and illuminates other nearby surfaces.
|
Radius | Ambient occlusion radius in units. It is the distance starting from the shadowed point and up to which the ray is traced. If an occlusion is met within this radius, the point is shadowed. If set to 0, calculation of the ambient occlusion is disabled. |
Samples | The number of ambient occlusion sampling rays. They are traced in random directions within a hemisphere that is around the shadowed point normal. |
Supersampling | Lightmap texture supersampling factor. The lightmap is rendered with higher resolution (X times bigger) and than downsampled to the defined light map texture size.
|
Extrude | Extrusion of light map contour in pixels. This parameter allows to get rid of dark rims at the edges. The areas in the light map texture, where a colored pixel borders with a fully transparent one (with zero alpha), are usually darkened when filtered by the video card. Extrusion parameter creates a colored outline (up to 4 pixels) from such transparent pixels by copying a color value and eliminates the problem. |
Blur | Blur filter factor in pixels. |
If any of Direct scale, Indirect scale, Extrude and Blur parameters are changed, Update LightMaps button allows very quick recalculation of lighting (without ray retracing).