This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

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

  1. 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.
  2. Setup dynamic lighting in the scene.
  3. 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.
  4. 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.
  5. 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).
  6. Open Tools -> Illumination tab:

    Illumination tab in tools panel

  7. Adjust parameters (see detailed description below).
  8. Click Create LightMaps button (the tool will bake lighting according to UV mapping into all lightmap textures specified in materials with lightmap state set).
  9. Check the result (use Enable LightMaps and Disable LightMaps buttons to quickly compare the original and the baked lighting result).
  10. Adjust parameters and re-bake light maps, if needed (use Update LightMaps button for faster re-baking).
  11. Select another set of objects and repeat the procedure (if different settings are needed).
  12. 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:

  1. Open Tools -> Illumination tab.
  2. Adjust LightProb settings.
  3. Click Create LightProbs button. A set of LightProb sources will be added into the node tree.
  4. 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

StepDistance between LightProbs in units when they are generated in a 3D grid around the selected object.
Near clippingThe 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 clippingFar clipping plane distance in units. It controls how far objects that are lit can be.
Bound meshAn optional mesh that bounds the lightmap calculation space.
Bound expandScale 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).
  • By the minimum value of 1.0, LightProbs are created only inside the selected mesh.
  • By higher values, LightProbs can light objects outside the bounding box of the mesh.
Merge thresholdSimilarity 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 scaleScale of direct illumination term. This is the light which comes directly from a light source:
  • The lower the value, the darker the light map colors will be.
  • The higher the value, the more colorful and saturated the light map colors will be.
Indirect scaleScale 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.
  • The higher the value, the more the lighter the light map colors will be.
RadiusAmbient 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.
SamplesThe number of ambient occlusion sampling rays. They are traced in random directions within a hemisphere that is around the shadowed point normal.
SupersamplingLightmap texture supersampling factor. The lightmap is rendered with higher resolution (X times bigger) and than downsampled to the defined light map texture size.
  • The higher the value, the more reduced aliasing, the nicer the shadows look, but the longer the light map creation takes.
ExtrudeExtrusion 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.
BlurBlur 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).

Notice
If you need HDR light maps, set Material -> Parameters -> Lightmap Scale parameter greater then 1.0 and use low values of Direct scale and Indirect scale during baking.
Last update: 2017-07-03
Build: ()