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¶
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
Methods¶
void |
Enumerations¶
enum Param:
PARAM_ENERGY = 0 --- Constant for accessing light_energy.
PARAM_INDIRECT_ENERGY = 1 --- Constant for accessing light_indirect_energy.
PARAM_SPECULAR = 2 --- Constant for accessing light_specular.
PARAM_RANGE = 3 --- Constant for accessing OmniLight3D.omni_range or SpotLight3D.spot_range.
PARAM_SIZE = 4 --- Constant for accessing light_size.
PARAM_ATTENUATION = 5 --- Constant for accessing OmniLight3D.omni_attenuation or SpotLight3D.spot_attenuation.
PARAM_SPOT_ANGLE = 6 --- Constant for accessing SpotLight3D.spot_angle.
PARAM_SPOT_ATTENUATION = 7 --- Constant for accessing SpotLight3D.spot_angle_attenuation.
PARAM_SHADOW_MAX_DISTANCE = 8 --- Constant for accessing DirectionalLight3D.directional_shadow_max_distance.
PARAM_SHADOW_SPLIT_1_OFFSET = 9 --- Constant for accessing DirectionalLight3D.directional_shadow_split_1.
PARAM_SHADOW_SPLIT_2_OFFSET = 10 --- Constant for accessing DirectionalLight3D.directional_shadow_split_2.
PARAM_SHADOW_SPLIT_3_OFFSET = 11 --- Constant for accessing DirectionalLight3D.directional_shadow_split_3.
PARAM_SHADOW_FADE_START = 12 --- Constant for accessing DirectionalLight3D.directional_shadow_fade_start.
PARAM_SHADOW_NORMAL_BIAS = 13 --- Constant for accessing shadow_normal_bias.
PARAM_SHADOW_BIAS = 14 --- Constant for accessing shadow_bias.
PARAM_SHADOW_PANCAKE_SIZE = 15 --- Constant for accessing DirectionalLight3D.directional_shadow_pancake_size.
PARAM_SHADOW_BLUR = 16 --- Constant for accessing shadow_blur.
PARAM_SHADOW_VOLUMETRIC_FOG_FADE = 17
PARAM_TRANSMITTANCE_BIAS = 18 --- Constant for accessing shadow_transmittance_bias.
PARAM_MAX = 19 --- Represents the size of the Param enum.
enum 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).
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.
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.
Property Descriptions¶
float distance_fade_begin
Default |
|
Setter |
set_distance_fade_begin(value) |
Getter |
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
Default |
|
Setter |
set_enable_distance_fade(value) |
Getter |
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
Default |
|
Setter |
set_distance_fade_length(value) |
Getter |
get_distance_fade_length() |
Distance over which the light fades. The light's energy is progressively reduced over this distance and is completely invisible at the end.
Note: Only effective for OmniLight3D and SpotLight3D.
float distance_fade_shadow
Default |
|
Setter |
set_distance_fade_shadow(value) |
Getter |
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
.
Note: Due to a rendering engine limitation, shadows will be disabled instantly instead of fading smoothly according to distance_fade_length. This may result in visible pop-in depending on the scene topography.
bool editor_only
Default |
|
Setter |
set_editor_only(value) |
Getter |
is_editor_only() |
If true
, the light only appears in the editor and will not be visible at runtime.
float light_angular_distance
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
The light's angular size in degrees. Increasing this will make shadows softer at greater distances. Only available for DirectionalLight3Ds. For reference, the Sun from the Earth is approximately 0.5
.
BakeMode light_bake_mode
Default |
|
Setter |
set_bake_mode(value) |
Getter |
get_bake_mode() |
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 GeometryInstance3D.gi_mode.
Color light_color
Default |
|
Setter |
set_color(value) |
Getter |
get_color() |
The light's color. An overbright color can be used to achieve a result equivalent to increasing the light's light_energy.
int light_cull_mask
Default |
|
Setter |
set_cull_mask(value) |
Getter |
get_cull_mask() |
The light will affect objects in the selected layers.
float light_energy
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
The light's strength multiplier (this is not a physical unit). For OmniLight3D and SpotLight3D, changing this value will only change the light color's intensity, not the light's radius.
float light_indirect_energy
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
Secondary multiplier used with indirect light (light bounces). Used with VoxelGI and SDFGI (see Environment.sdfgi_enabled).
Note: This property is ignored if light_energy is equal to 0.0
, as the light won't be present at all in the GI shader.
bool light_negative
Default |
|
Setter |
set_negative(value) |
Getter |
is_negative() |
If true
, the light's effect is reversed, darkening areas and casting bright shadows.
Texture2D light_projector
Setter |
set_projector(value) |
Getter |
get_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.
float light_size
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
The size of the light in Godot units. Only available for OmniLight3Ds and SpotLight3Ds. Increasing this value will make the light fade out slower and shadows appear blurrier. This can be used to simulate area lights to an extent.
float light_specular
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
The intensity of the specular blob in objects affected by the light. At 0
, 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.
float shadow_bias
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
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.
float shadow_blur
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
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.
bool shadow_enabled
Default |
|
Setter |
set_shadow(value) |
Getter |
has_shadow() |
If true
, 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 using distance_fade_enabled to hide the light when far away from the Camera3D.
float shadow_fog_fade
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
float shadow_normal_bias
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
Offsets the lookup into the shadow map by the object's normal. This can be used to reduce self-shadowing artifacts without using shadow_bias. In practice, this value should be tweaked along with shadow_bias to reduce artifacts as much as possible.
bool shadow_reverse_cull_face
Default |
|
Setter |
set_shadow_reverse_cull_face(value) |
Getter |
get_shadow_reverse_cull_face() |
If true
, 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 with GeometryInstance3D.SHADOW_CASTING_SETTING_DOUBLE_SIDED.
float shadow_transmittance_bias
Default |
|
Setter |
set_param(value) |
Getter |
get_param() |
Method Descriptions¶
Returns the value of the specified Param parameter.
Sets the value of the specified Param parameter.