Up to date

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

Light3D

Inherits: VisualInstance3D < Node3D < Node < Object

Inherited By: DirectionalLight3D, OmniLight3D, SpotLight3D

Provides a base class for different kinds of light nodes.

Description

Light3D is the abstract base class for light nodes. As it can't be instantiated, it shouldn't be used directly. Other types of light nodes inherit from it. Light3D contains the common variables and parameters used for lighting.

Tutorials

Properties

float

distance_fade_begin

40.0

bool

distance_fade_enabled

false

float

distance_fade_length

10.0

float

distance_fade_shadow

50.0

bool

editor_only

false

float

light_angular_distance

0.0

BakeMode

light_bake_mode

2

Color

light_color

Color(1, 1, 1, 1)

int

light_cull_mask

4294967295

float

light_energy

1.0

float

light_indirect_energy

1.0

float

light_intensity_lumens

float

light_intensity_lux

bool

light_negative

false

Texture2D

light_projector

float

light_size

0.0

float

light_specular

0.5

float

light_temperature

float

light_volumetric_fog_energy

1.0

float

shadow_bias

0.1

float

shadow_blur

1.0

bool

shadow_enabled

false

float

shadow_normal_bias

2.0

float

shadow_opacity

1.0

bool

shadow_reverse_cull_face

false

float

shadow_transmittance_bias

0.05

Methods

Color

get_correlated_color ( ) const

float

get_param ( Param param ) const

void

set_param ( Param param, float value )


Enumerations

enum Param:

Param PARAM_ENERGY = 0

Constant for accessing light_energy.

Param PARAM_INDIRECT_ENERGY = 1

Constant for accessing light_indirect_energy.

Param PARAM_VOLUMETRIC_FOG_ENERGY = 2

Constant for accessing light_volumetric_fog_energy.

Param PARAM_SPECULAR = 3

Constant for accessing light_specular.

Param PARAM_RANGE = 4

Constant for accessing OmniLight3D.omni_range or SpotLight3D.spot_range.

Param PARAM_SIZE = 5

Constant for accessing light_size.

Param PARAM_ATTENUATION = 6

Constant for accessing OmniLight3D.omni_attenuation or SpotLight3D.spot_attenuation.

Param PARAM_SPOT_ANGLE = 7

Constant for accessing SpotLight3D.spot_angle.

Param PARAM_SPOT_ATTENUATION = 8

Constant for accessing SpotLight3D.spot_angle_attenuation.

Param PARAM_SHADOW_MAX_DISTANCE = 9

Constant for accessing DirectionalLight3D.directional_shadow_max_distance.

Param PARAM_SHADOW_SPLIT_1_OFFSET = 10

Constant for accessing DirectionalLight3D.directional_shadow_split_1.

Param PARAM_SHADOW_SPLIT_2_OFFSET = 11

Constant for accessing DirectionalLight3D.directional_shadow_split_2.

Param PARAM_SHADOW_SPLIT_3_OFFSET = 12

Constant for accessing DirectionalLight3D.directional_shadow_split_3.

Param PARAM_SHADOW_FADE_START = 13

Constant for accessing DirectionalLight3D.directional_shadow_fade_start.

Param PARAM_SHADOW_NORMAL_BIAS = 14

Constant for accessing shadow_normal_bias.

Param PARAM_SHADOW_BIAS = 15

Constant for accessing shadow_bias.

Param PARAM_SHADOW_PANCAKE_SIZE = 16

Constant for accessing DirectionalLight3D.directional_shadow_pancake_size.

Param PARAM_SHADOW_OPACITY = 17

Constant for accessing shadow_opacity.

Param PARAM_SHADOW_BLUR = 18

Constant for accessing shadow_blur.

Param PARAM_TRANSMITTANCE_BIAS = 19

Constant for accessing shadow_transmittance_bias.

Param PARAM_INTENSITY = 20

Constant for accessing light_intensity_lumens and light_intensity_lux. Only used when ProjectSettings.rendering/lights_and_shadows/use_physical_light_units is true.

Param PARAM_MAX = 21

Represents the size of the Param enum.


enum BakeMode:

BakeMode BAKE_DISABLED = 0

Light is ignored when baking. This is the fastest mode, but the light will be taken into account when baking global illumination. This mode should generally be used for dynamic lights that change quickly, as the effect of global illumination is less noticeable on those lights.

Note: Hiding a light does not affect baking LightmapGI. Hiding a light will still affect baking VoxelGI and SDFGI (see [member Environment.sdfgi_enabled).

BakeMode BAKE_STATIC = 1

Light is taken into account in static baking (VoxelGI, LightmapGI, SDFGI (Environment.sdfgi_enabled)). The light can be moved around or modified, but its global illumination will not update in real-time. This is suitable for subtle changes (such as flickering torches), but generally not large changes such as toggling a light on and off.

BakeMode BAKE_DYNAMIC = 2

Light is taken into account in dynamic baking (VoxelGI and SDFGI (Environment.sdfgi_enabled) only). The light can be moved around or modified with global illumination updating in real-time. The light's global illumination appearance will be slightly different compared to BAKE_STATIC. This has a greater performance cost compared to BAKE_STATIC. When using SDFGI, the update speed of dynamic lights is affected by ProjectSettings.rendering/global_illumination/sdfgi/frames_to_update_lights.


Property Descriptions

float distance_fade_begin = 40.0

  • void set_distance_fade_begin ( float value )

  • float get_distance_fade_begin ( )

The distance from the camera at which the light begins to fade away (in 3D units).

Note: Only effective for OmniLight3D and SpotLight3D.


bool distance_fade_enabled = false

  • void set_enable_distance_fade ( bool value )

  • bool is_distance_fade_enabled ( )

If true, the light will smoothly fade away when far from the active Camera3D starting at distance_fade_begin. This acts as a form of level of detail (LOD). The light will fade out over distance_fade_begin + distance_fade_length, after which it will be culled and not sent to the shader at all. Use this to reduce the number of active lights in a scene and thus improve performance.

Note: Only effective for OmniLight3D and SpotLight3D.


float distance_fade_length = 10.0

  • void set_distance_fade_length ( float value )

  • float get_distance_fade_length ( )

Distance over which the light and its shadow fades. The light's energy and shadow's opacity is progressively reduced over this distance and is completely invisible at the end.

Note: Only effective for OmniLight3D and SpotLight3D.


float distance_fade_shadow = 50.0

  • void set_distance_fade_shadow ( float value )

  • float get_distance_fade_shadow ( )

The distance from the camera at which the light's shadow cuts off (in 3D units). Set this to a value lower than distance_fade_begin + distance_fade_length to further improve performance, as shadow rendering is often more expensive than light rendering itself.

Note: Only effective for OmniLight3D and SpotLight3D, and only when shadow_enabled is true.


bool editor_only = false

  • void set_editor_only ( bool value )

  • bool is_editor_only ( )

If true, the light only appears in the editor and will not be visible at runtime.


float light_angular_distance = 0.0

The light's angular size in degrees. Increasing this will make shadows softer at greater distances (also called percentage-closer soft shadows, or PCSS). Only available for DirectionalLight3Ds. For reference, the Sun from the Earth is approximately 0.5. Increasing this value above 0.0 for lights with shadows enabled will have a noticeable performance cost due to PCSS.

Note: light_angular_distance is not affected by Node3D.scale (the light's scale or its parent's scale).

Note: PCSS for directional lights is only supported in the Forward+ rendering method, not Mobile or Compatibility.


BakeMode light_bake_mode = 2

The light's bake mode. This will affect the global illumination techniques that have an effect on the light's rendering. See BakeMode.

Note: Meshes' global illumination mode will also affect the global illumination rendering. See