Class LightmapGI
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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 GenerateProbesSubdiv to a value other than 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 SdfgiEnabled).
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. Additionally, LightmapGI rendering is not currently supported when using the OpenGL backend (Compatibility).
public class LightmapGI : VisualInstance3D, IDisposable
- Inheritance
-
LightmapGI
- Implements
- Inherited Members
Constructors
LightmapGI()
public LightmapGI()
Properties
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.
public float Bias { get; set; }
Property Value
BounceIndirectEnergy
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 BounceIndirectEnergy.
Note:
BounceIndirectEnergy only has an effect if Bounces is set to a value greater than or equal to 1
.
public float BounceIndirectEnergy { get; set; }
Property Value
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.
public int Bounces { get; set; }
Property Value
CameraAttributes
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.
public CameraAttributes CameraAttributes { get; set; }
Property Value
DenoiserStrength
The strength of denoising step applied to the generated lightmaps. Only effective if UseDenoiser is true
and ProjectSettings.rendering/lightmapping/denoising/denoiser
is set to JNLM.
public float DenoiserStrength { get; set; }
Property Value
Directional
If true
, bakes lightmaps to contain directional information as spherical harmonics. This results in more realistic lighting appearance, especially with normal mapped materials and for lights that have their direct light baked (LightBakeMode set to Static and with EditorOnly set to false
). The directional information is also used to provide rough reflections for static and dynamic objects. This has a small run-time performance cost as the shader has to perform more work to interpret the direction information from the lightmap. Directional lightmaps also take longer to bake and result in larger file sizes.
Note: The property's name has no relationship with DirectionalLight3D. Directional works with all light types.
public bool Directional { get; set; }
Property Value
EnvironmentCustomColor
The color to use for environment lighting. Only effective if EnvironmentMode is CustomColor.
public Color EnvironmentCustomColor { get; set; }
Property Value
EnvironmentCustomEnergy
The color multiplier to use for environment lighting. Only effective if EnvironmentMode is CustomColor.
public float EnvironmentCustomEnergy { get; set; }
Property Value
EnvironmentCustomSky
The sky to use as a source of environment lighting. Only effective if EnvironmentMode is CustomSky.
public Sky EnvironmentCustomSky { get; set; }
Property Value
EnvironmentMode
The environment mode to use when baking lightmaps.
public LightmapGI.EnvironmentModeEnum EnvironmentMode { get; set; }
Property Value
GenerateProbesSubdiv
The level of subdivision to use when automatically generating LightmapProbes for dynamic object lighting. Higher values result in more accurate indirect lighting on dynamic objects, at the cost of longer bake times and larger file sizes.
Note: Automatically generated LightmapProbes are not visible as nodes in the Scene tree dock, and cannot be modified this way after they are generated.
Note: Regardless of GenerateProbesSubdiv, direct lighting on dynamic objects is always applied using Light3D nodes in real-time.
public LightmapGI.GenerateProbes GenerateProbesSubdiv { get; set; }
Property Value
Interior
If true
, ignore environment lighting when baking lightmaps.
public bool Interior { get; set; }
Property Value
LightData
The LightmapGIData associated to this LightmapGI node. This resource is automatically created after baking, and is not meant to be created manually.
public LightmapGIData LightData { get; set; }
Property Value
MaxTextureSize
The maximum texture size for the generated texture atlas. Higher values will result in fewer slices being generated, but may not work on all hardware as a result of hardware limitations on texture sizes. Leave MaxTextureSize at its default value of 16384
if unsure.
public int MaxTextureSize { get; set; }
Property Value
Quality
The quality preset to use when baking lightmaps. This affects bake times, but output file sizes remain mostly identical across quality levels.
To further speed up bake times, decrease Bounces, disable UseDenoiser and increase the lightmap texel size on 3D scenes in the Import doc.
public LightmapGI.BakeQuality Quality { get; set; }
Property Value
UseDenoiser
If true
, uses a GPU-based denoising algorithm on the generated lightmap. This eliminates most noise within the generated lightmap at the cost of longer bake times. File sizes are generally not impacted significantly by the use of a denoiser, although lossless compression may do a better job at compressing a denoised image.
public bool UseDenoiser { get; set; }
Property Value
UseTextureForBounces
If true
, a texture with the lighting information will be generated to speed up the generation of indirect lighting at the cost of some accuracy. The geometry might exhibit extra light leak artifacts when using low resolution lightmaps or UVs that stretch the lightmap significantly across surfaces. Leave UseTextureForBounces at its default value of true
if unsure.
Note:
UseTextureForBounces only has an effect if Bounces is set to a value greater than or equal to 1
.
public bool UseTextureForBounces { get; set; }
Property Value
Methods
HasGodotClassMethod(in godot_string_name)
Check if the type contains a method with the given name. This method is used by Godot to check if a method exists before invoking it. Do not call or override this method.
protected override bool HasGodotClassMethod(in godot_string_name method)
Parameters
method
godot_string_nameName of the method to check for.
Returns
HasGodotClassSignal(in godot_string_name)
Check if the type contains a signal with the given name. This method is used by Godot to check if a signal exists before raising it. Do not call or override this method.
protected override bool HasGodotClassSignal(in godot_string_name signal)
Parameters
signal
godot_string_nameName of the signal to check for.
Returns
InvokeGodotClassMethod(in godot_string_name, NativeVariantPtrArgs, out godot_variant)
Invokes the method with the given name, using the given arguments. This method is used by Godot to invoke methods from the engine side. Do not call or override this method.
protected override bool InvokeGodotClassMethod(in godot_string_name method, NativeVariantPtrArgs args, out godot_variant ret)
Parameters
method
godot_string_nameName of the method to invoke.
args
NativeVariantPtrArgsArguments to use with the invoked method.
ret
godot_variantValue returned by the invoked method.