Lightmapping

    Cocos Creator automatically processes and uses the generated lightmap at runtime. In scenes with fixed lights, using lightmaps instead of real-time lighting calculations can reduce resource consumption and thus increase the efficiency of the scene.

    Click Project -> Lightmapping in the editor menu bar to open the Lightmapping panel. The panel consists of two pages, Scene and Baked.

    • Scene: mainly used to configure the parameters related to generating the lightmap.
    • Baked: mainly used to display the generated lightmap and its related information.

    For details, please see the Generating Lightmaps section below.

    The description of each property on the Scene page is as follows:

    Generating lightmaps

    1. Select the node with the light component in the Hierarchy panel, then set the StaticSettings of the light component in the Inspector panel, and check the property (currently multiple are not supported).

      enable lightbake

      • EditorOnly: whether to take effect only in the editor

    2. Select the node with the MeshRenderer component in the Hierarchy panel to generate the lightmap, then set LightmapSettings in the Inspector panel and check the property.

      • Bakeable: whether to bake static lighting

      • CastShadow: whether to cast static shadows

      • ReceiveShadow: whether to receive static shadows

      • LightmapSize: the size of the model lightmap

    3. lightmap UVs Unlike texture UVs, lightmap UVs cannot overlap

      Notes:Incorrect UVs produce errors:

      1. UV of different planes are interlaced

        lightmap uv overlap lightmap uv overlap

      2. There is no reserved interval between UV blocks

    4. Open the Lightmapping panel and set the corresponding properties. Then click the Lightmap Generate button, a file storage dialog will pop up, you need to specify a folder (must be in the directory) to store the generated lightmap data information. Notice the baking progress log at the bottom of the Lightmapping panel.

      bake param

    5. After baking, the generated lightmap, as well as the file name, size and other related information can be viewed on the Baked page of the Lightmapping panel. The generated lightmaps are automatically processed by the engine and do not need to be manipulated by the developer.

      1. Bake result: shows the generated lightmap after baking, in format RGBE8, with R/G/B options to view the corresponding channels of the lightmap as required.
      2. Lightmap clear: used to delete the generated lightmap and related information.