Light3D

Inherits:VisualInstance3D<Node3D<Node<Object

Inherited By:DirectionalLight3D,OmniLight3D,SpotLight3D

Provides a base class for different kinds of light nodes.

Description

Light3D is theabstract 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

1.0

float

light_temperature

float

light_volumetric_fog_energy

1.0

float

shadow_bias

0.1

float

shadow_blur

1.0

int

shadow_caster_mask

4294967295

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, value:float)


Enumerations

enumParam:🔗

ParamPARAM_ENERGY =0

Constant for accessinglight_energy.

ParamPARAM_INDIRECT_ENERGY =1

Constant for accessinglight_indirect_energy.

ParamPARAM_VOLUMETRIC_FOG_ENERGY =2

Constant for accessinglight_volumetric_fog_energy.

ParamPARAM_SPECULAR =3

Constant for accessinglight_specular.

ParamPARAM_RANGE =4

Constant for accessingOmniLight3D.omni_range orSpotLight3D.spot_range.

ParamPARAM_SIZE =5

Constant for accessinglight_size.

ParamPARAM_ATTENUATION =6

Constant for accessingOmniLight3D.omni_attenuation orSpotLight3D.spot_attenuation.

ParamPARAM_SPOT_ANGLE =7

Constant for accessingSpotLight3D.spot_angle.

ParamPARAM_SPOT_ATTENUATION =8

Constant for accessingSpotLight3D.spot_angle_attenuation.

ParamPARAM_SHADOW_MAX_DISTANCE =9

Constant for accessingDirectionalLight3D.directional_shadow_max_distance.

ParamPARAM_SHADOW_SPLIT_1_OFFSET =10

Constant for accessingDirectionalLight3D.directional_shadow_split_1.

ParamPARAM_SHADOW_SPLIT_2_OFFSET =11

Constant for accessingDirectionalLight3D.directional_shadow_split_2.

ParamPARAM_SHADOW_SPLIT_3_OFFSET =12

Constant for accessingDirectionalLight3D.directional_shadow_split_3.

ParamPARAM_SHADOW_FADE_START =13

Constant for accessingDirectionalLight3D.directional_shadow_fade_start.

ParamPARAM_SHADOW_NORMAL_BIAS =14

Constant for accessingshadow_normal_bias.

ParamPARAM_SHADOW_BIAS =15

Constant for accessingshadow_bias.

ParamPARAM_SHADOW_PANCAKE_SIZE =16

Constant for accessingDirectionalLight3D.directional_shadow_pancake_size.

ParamPARAM_SHADOW_OPACITY =17

Constant for accessingshadow_opacity.

ParamPARAM_SHADOW_BLUR =18

Constant for accessingshadow_blur.

ParamPARAM_TRANSMITTANCE_BIAS =19

Constant for accessingshadow_transmittance_bias.

ParamPARAM_INTENSITY =20

Constant for accessinglight_intensity_lumens andlight_intensity_lux. Only used whenProjectSettings.rendering/lights_and_shadows/use_physical_light_units istrue.

ParamPARAM_MAX =21

Represents the size of theParam enum.


enumBakeMode:🔗

BakeModeBAKE_DISABLED =0

Light is ignored when baking. This is the fastest mode, but the light will not 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 doesnot affect bakingLightmapGI. Hiding a light will still affect bakingVoxelGI and SDFGI (seeEnvironment.sdfgi_enabled).

BakeModeBAKE_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.

Note: The light is not baked inLightmapGI ifeditor_only istrue.

BakeModeBAKE_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 toBAKE_STATIC. This has a greater performance cost compared toBAKE_STATIC. When using SDFGI, the update speed of dynamic lights is affected byProjectSettings.rendering/global_illumination/sdfgi/frames_to_update_lights.


Property Descriptions

floatdistance_fade_begin =40.0🔗

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

Note: Only effective forOmniLight3D andSpotLight3D.


booldistance_fade_enabled =false🔗

Iftrue, the light will smoothly fade away when far from the activeCamera3D starting atdistance_fade_begin. This acts as a form of level of detail (LOD). The light will fade out overdistance_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 forOmniLight3D andSpotLight3D.


floatdistance_fade_length =10.0🔗

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 forOmniLight3D andSpotLight3D.


floatdistance_fade_shadow =50.0🔗

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

Note: Only effective forOmniLight3D andSpotLight3D, and only whenshadow_enabled istrue.


booleditor_only =false🔗

Iftrue, the light only appears in the editor and will not be visible at runtime. Iftrue, the light will never be baked inLightmapGI regardless of itslight_bake_mode.


floatlight_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 forDirectionalLight3Ds. For reference, the Sun from the Earth is approximately0.5. Increasing this value above0.0 for lights with shadows enabled will have a noticeable performance cost due to PCSS.

Note:light_angular_distance is not affected byNode3D.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.


BakeModelight_bake_mode =2🔗

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

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


Colorlight_color =Color(1,1,1,1)🔗

The light's color in the nonlinear sRGB color space. Anoverbright color can be used to achieve a result equivalent to increasing the light'slight_energy.


intlight_cull_mask =4294967295🔗

The light will affect objects in the selected layers.


floatlight_energy =1.0🔗

The light's strength multiplier (this is not a physical unit). ForOmniLight3D andSpotLight3D, changing this value will only change the light color's intensity, not the light's radius.


floatlight_indirect_energy =1.0🔗

Secondary multiplier used with indirect light (light bounces). Used withVoxelGI and SDFGI (seeEnvironment.sdfgi_enabled).

Note: This property is ignored iflight_energy is equal to0.0, as the light won't be present at all in the GI shader.


floatlight_intensity_lumens🔗

Used by positional lights (OmniLight3D andSpotLight3D) whenProjectSettings.rendering/lights_and_shadows/use_physical_light_units istrue. Sets the intensity of the light source measured in Lumens. Lumens are a measure of luminous flux, which is the total amount of visible light emitted by a light source per unit of time.

ForSpotLight3Ds, we assume that the area outside the visible cone is surrounded by a perfect light absorbing material. Accordingly, the apparent brightness of the cone area does not change as the cone increases and decreases in size.

A typical household lightbulb can range from around 600 lumens to 1,200 lumens, a candle is about 13 lumens, while a streetlight can be approximately 60,000 lumens.


floatlight_intensity_lux🔗

Used byDirectionalLight3Ds whenProjectSettings.rendering/lights_and_shadows/use_physical_light_units istrue. Sets the intensity of the light source measured in Lux. Lux is a measure of luminous flux per unit area, it is equal to one lumen per square meter. Lux is the measure of how much light hits a surface at a given time.

On a clear sunny day a surface in direct sunlight may be approximately 100,000 lux, a typical room in a home may be approximately 50 lux, while the moonlit ground may be approximately 0.1 lux.


boollight_negative =false🔗

Iftrue, the light's effect is reversed, darkening areas and casting bright shadows.


Texture2Dlight_projector🔗

Texture2D projected by light.shadow_enabled must be on for the projector to work. Light projectors make the light appear as if it is shining through a colored but transparent object, almost like light shining through stained-glass.

Note: UnlikeBaseMaterial3D whose filter mode can be adjusted on a per-material basis, the filter mode for light projector textures is set globally withProjectSettings.rendering/textures/light_projectors/filter.

Note: Light projector textures are only supported in the Forward+ and Mobile rendering methods, not Compatibility.


floatlight_size =0.0🔗

The size of the light in Godot units. Only available forOmniLight3Ds andSpotLight3Ds. Increasing this value will make the light fade out slower and shadows appear blurrier (also called percentage-closer soft shadows, or PCSS). This can be used to simulate area lights to an extent. Increasing this value above0.0 for lights with shadows enabled will have a noticeable performance cost due to PCSS.

Note:light_size is not affected byNode3D.scale (the light's scale or its parent's scale).

Note: PCSS for positional lights is only supported in the Forward+ and Mobile rendering methods, not Compatibility.


floatlight_specular =1.0🔗

The intensity of the specular blob in objects affected by the light. At0, the light becomes a pure diffuse light. When not baking emission, this can be used to avoid unrealistic reflections when placing lights above an emissive surface.


floatlight_temperature🔗

Sets the color temperature of the light source, measured in Kelvin. This is used to calculate a correlated color temperature which tints thelight_color.

The sun on a cloudy day is approximately 6500 Kelvin, on a clear day it is between 5500 to 6000 Kelvin, and on a clear day at sunrise or sunset it ranges to around 1850 Kelvin.


floatlight_volumetric_fog_energy =1.0🔗

Secondary multiplier multiplied withlight_energy then used with theEnvironment's volumetric fog (if enabled). If set to0.0, computing volumetric fog will be skipped for this light, which can improve performance for large amounts of lights when volumetric fog is enabled.

Note: To prevent short-lived dynamic light effects from poorly interacting with volumetric fog, lights used in those effects should havelight_volumetric_fog_energy set to0.0 unlessEnvironment.volumetric_fog_temporal_reprojection_enabled is disabled (or unless the reprojection amount is significantly lowered).


floatshadow_bias =0.1🔗

Used to adjust shadow appearance. Too small a value results in self-shadowing ("shadow acne"), while too large a value causes shadows to separate from casters ("peter-panning"). Adjust as needed.


floatshadow_blur =1.0🔗

Blurs the edges of the shadow. Can be used to hide pixel artifacts in low-resolution shadow maps. A high value can impact performance, make shadows appear grainy and can cause other unwanted artifacts. Try to keep as near default as possible.


intshadow_caster_mask =4294967295🔗

The light will only cast shadows using objects in the selected layers.


boolshadow_enabled =false🔗

Iftrue, the light will cast real-time shadows. This has a significant performance cost. Only enable shadow rendering when it makes a noticeable difference in the scene's appearance, and consider usingdistance_fade_enabled to hide the light when far away from theCamera3D.


floatshadow_normal_bias =2.0🔗

Offsets the lookup into the shadow map by the object's normal. This can be used to reduce self-shadowing artifacts without usingshadow_bias. In practice, this value should be tweaked along withshadow_bias to reduce artifacts as much as possible.


floatshadow_opacity =1.0🔗

The opacity to use when rendering the light's shadow map. Values lower than1.0 make the light appear through shadows. This can be used to fake global illumination at a low performance cost.


boolshadow_reverse_cull_face =false🔗

Iftrue, reverses the backface culling of the mesh. This can be useful when you have a flat mesh that has a light behind it. If you need to cast a shadow on both sides of the mesh, set the mesh to use double-sided shadows withGeometryInstance3D.SHADOW_CASTING_SETTING_DOUBLE_SIDED.


floatshadow_transmittance_bias =0.05🔗


Method Descriptions

Colorget_correlated_color()const🔗

Returns theColor of an idealized blackbody at the givenlight_temperature. This value is calculated internally based on thelight_temperature. ThisColor is multiplied bylight_color before being sent to theRenderingServer.


floatget_param(param:Param)const🔗

Returns the value of the specifiedParam parameter.


voidset_param(param:Param, value:float)🔗

Sets the value of the specifiedParam parameter.


User-contributed notes

Please read theUser-contributed notes policy before submitting a comment.