Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

LightmapGI

Inherits: VisualInstance3D < Node3D < Node < Object

Computes and stores baked lightmaps for fast global illumination.

Description

The LightmapGI node is used to compute and store baked lightmaps. Lightmaps are used to provide high-quality indirect lighting with very little light leaking. LightmapGI can also provide rough reflections using spherical harmonics if directional is enabled. Dynamic objects can receive indirect lighting thanks to light probes, which can be automatically placed by setting generate_probes_subdiv to a value other than GENERATE_PROBES_DISABLED. Additional lightmap probes can also be added by creating LightmapProbe nodes. The downside is that lightmaps are fully static and cannot be baked in an exported project. Baking a LightmapGI node is also slower compared to VoxelGI.

Procedural generation: Lightmap baking functionality is only available in the editor. This means LightmapGI is not suited to procedurally generated or user-built levels. For procedurally generated or user-built levels, use VoxelGI or SDFGI instead (see Environment.sdfgi_enabled).

Performance: LightmapGI provides the best possible run-time performance for global illumination. It is suitable for low-end hardware including integrated graphics and mobile devices.

Note: Due to how lightmaps work, most properties only have a visible effect once lightmaps are baked again.

Note: Lightmap baking on CSGShape3Ds and PrimitiveMeshes is not supported, as these cannot store UV2 data required for baking.

Note: If no custom lightmappers are installed, LightmapGI can only be baked when using the Vulkan backend (Forward+ or Mobile), not OpenGL.

Tutorials

Properties

float

bias

0.0005

float

bounce_indirect_energy

1.0

int

bounces

3

CameraAttributes

camera_attributes

float

denoiser_strength

0.1

bool

directional

false

Color

environment_custom_color

float

environment_custom_energy

Sky

environment_custom_sky

EnvironmentMode

environment_mode

1

GenerateProbes

generate_probes_subdiv

2

bool

interior

false

LightmapGIData

light_data

int

max_texture_size

16384

BakeQuality

quality

1

bool

use_denoiser

true

bool

use_texture_for_bounces

true


Enumerations

enum BakeQuality:

BakeQuality BAKE_QUALITY_LOW = 0

Low bake quality (fastest bake times). The quality of this preset can be adjusted by changing ProjectSettings.rendering/lightmapping/bake_quality/low_quality_ray_count and ProjectSettings.rendering/lightmapping/bake_quality/low_quality_probe_ray_count.

BakeQuality BAKE_QUALITY_MEDIUM = 1

Medium bake quality (fast bake times). The quality of this preset can be adjusted by changing ProjectSettings.rendering/lightmapping/bake_quality/medium_quality_ray_count and ProjectSettings.rendering/lightmapping/bake_quality/medium_quality_probe_ray_count.

BakeQuality BAKE_QUALITY_HIGH = 2

High bake quality (slow bake times). The quality of this preset can be adjusted by changing ProjectSettings.rendering/lightmapping/bake_quality/high_quality_ray_count and ProjectSettings.rendering/lightmapping/bake_quality/high_quality_probe_ray_count.

BakeQuality BAKE_QUALITY_ULTRA = 3

Highest bake quality (slowest bake times). The quality of this preset can be adjusted by changing ProjectSettings.rendering/lightmapping/bake_quality/ultra_quality_ray_count and ProjectSettings.rendering/lightmapping/bake_quality/ultra_quality_probe_ray_count.


enum GenerateProbes:

GenerateProbes GENERATE_PROBES_DISABLED = 0

Don't generate lightmap probes for lighting dynamic objects.

GenerateProbes GENERATE_PROBES_SUBDIV_4 = 1

Lowest level of subdivision (fastest bake times, smallest file sizes).

GenerateProbes GENERATE_PROBES_SUBDIV_8 = 2

Low level of subdivision (fast bake times, small file sizes).

GenerateProbes GENERATE_PROBES_SUBDIV_16 = 3

High level of subdivision (slow bake times, large file sizes).

GenerateProbes GENERATE_PROBES_SUBDIV_32 = 4

Highest level of subdivision (slowest bake times, largest file sizes).


enum BakeError:

BakeError BAKE_ERROR_OK = 0

Lightmap baking was successful.

BakeError BAKE_ERROR_NO_SCENE_ROOT = 1

Lightmap baking failed because the root node for the edited scene could not be accessed.

BakeError BAKE_ERROR_FOREIGN_DATA = 2

Lightmap baking failed as the lightmap data resource is embedded in a foreign resource.

BakeError BAKE_ERROR_NO_LIGHTMAPPER = 3

Lightmap baking failed as there is no lightmapper available in this Godot build.

BakeError BAKE_ERROR_NO_SAVE_PATH = 4

Lightmap baking failed as the LightmapGIData save path isn't configured in the resource.

BakeError BAKE_ERROR_NO_MESHES = 5

Lightmap baking failed as there are no meshes whose GeometryInstance3D.gi_mode is GeometryInstance3D.GI_MODE_STATIC and with valid UV2 mapping in the current scene. You may need to select 3D scenes in the Import dock and change their global illumination mode accordingly.

BakeError BAKE_ERROR_MESHES_INVALID = 6

Lightmap baking failed as the lightmapper failed to analyze some of the meshes marked as static for baking.

BakeError BAKE_ERROR_CANT_CREATE_IMAGE = 7

Lightmap baking failed as the resulting image couldn't be saved or imported by Godot after it was saved.

BakeError BAKE_ERROR_USER_ABORTED = 8

The user aborted the lightmap baking operation (typically by clicking the Cancel button in the progress dialog).

BakeError BAKE_ERROR_TEXTURE_SIZE_TOO_SMALL = 9

Lightmap baking failed as the maximum texture size is too small to fit some of the meshes marked for baking.


enum EnvironmentMode:

EnvironmentMode ENVIRONMENT_MODE_DISABLED = 0

Ignore environment lighting when baking lightmaps.

EnvironmentMode ENVIRONMENT_MODE_SCENE = 1

Use the scene's environment lighting when baking lightmaps.

Note: If baking lightmaps in a scene with no WorldEnvironment node, this will act like ENVIRONMENT_MODE_DISABLED. The editor's preview sky and sun is not taken into account by LightmapGI when baking lightmaps.

EnvironmentMode ENVIRONMENT_MODE_CUSTOM_SKY = 2

Use environment_custom_sky as a source of environment lighting when baking lightmaps.

EnvironmentMode ENVIRONMENT_MODE_CUSTOM_COLOR = 3

Use environment_custom_color multiplied by environment_custom_energy as a constant source of environment lighting when baking lightmaps.


Property Descriptions

float bias = 0.0005

  • void set_bias ( float value )

  • float get_bias ( )

The bias to use when computing shadows. Increasing bias can fix shadow acne on the resulting baked lightmap, but can introduce peter-panning (shadows not connecting to their casters). Real-time Light3D shadows are not affected by this bias property.


float bounce_indirect_energy = 1.0

  • void set_bounce_indirect_energy ( float value )

  • float get_bounce_indirect_energy ( )

The energy multiplier for each bounce. Higher values will make indirect lighting brighter. A value of 1.0 represents physically accurate behavior, but higher values can be used to make indirect lighting propagate more visibly when using a low number of bounces. This can be used to speed up bake times by lowering the number of bounces then increasing bounce_indirect_energy.

Note: bounce_indirect_energy only has an effect if bounces is set to a value greater than or equal to 1.


int bounces = 3

  • void set_bounces ( int value )

  • int get_bounces ( )

Number of light bounces that are taken into account during baking. Higher values result in brighter, more realistic lighting, at the cost of longer bake times. If set to 0, only environment lighting, direct light and emissive lighting is baked.


CameraAttributes camera_attributes

The CameraAttributes resource that specifies exposure levels to bake at. Auto-exposure and non exposure properties will be ignored. Exposure settings should be used to reduce the dynamic range present when baking. If exposure is too high, the LightmapGI will have banding artifacts or may have over-exposure artifacts.


float denoiser_strength = 0.1