Light
Inherited By: DirectionalLight, , SpotLight
Provides a base class for different kinds of light nodes.
Light is the abstract base class for light nodes. As it can’t be instanced, it shouldn’t be used directly. Other types of light nodes inherit from it. Light contains the common variables and parameters used for lighting.
Tutorials
Methods
get_param ( param ) const | |
void |
enum Param:
PARAM_ENERGY = 0 —- Constant for accessing light_energy.
PARAM_INDIRECT_ENERGY = 1 —- Constant for accessing .
PARAM_SIZE = 2 —- Constant for accessing light_size.
PARAM_SPECULAR = 3 —- Constant for accessing .
PARAM_RANGE = 4 —- Constant for accessing OmniLight.omni_range or .
PARAM_SPOT_ANGLE = 6 —- Constant for accessing SpotLight.spot_angle.
PARAM_SPOT_ATTENUATION = 7 —- Constant for accessing .
PARAM_CONTACT_SHADOW_SIZE = 8 —- Constant for accessing shadow_contact.
PARAM_SHADOW_MAX_DISTANCE = 9 —- Constant for accessing .
PARAM_SHADOW_SPLIT_1_OFFSET = 10 —- Constant for accessing DirectionalLight.directional_shadow_split_1.
PARAM_SHADOW_SPLIT_2_OFFSET = 11 —- Constant for accessing .
PARAM_SHADOW_SPLIT_3_OFFSET = 12 —- Constant for accessing DirectionalLight.directional_shadow_split_3.
PARAM_SHADOW_NORMAL_BIAS = 13 —- Constant for accessing .
PARAM_SHADOW_BIAS = 14 —- Constant for accessing shadow_bias.
PARAM_SHADOW_BIAS_SPLIT_SCALE = 15 —- Constant for accessing .
PARAM_MAX = 16 —- Represents the size of the Param enum.
enum BakeMode:
- BAKE_DISABLED = 0 —- Light is ignored when baking.
Note: Hiding a light does not affect baking.
BAKE_INDIRECT = 1 —- Only indirect lighting will be baked (default).
BAKE_ALL = 2 —- Both direct and indirect light will be baked.
Note: You should hide the light if you don’t want it to appear twice (dynamic and baked).
Property Descriptions
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.
- BakeMode light_bake_mode
Default |
|
Setter | set_bake_mode(value) |
Getter | get_bake_mode() |
The light’s bake mode. See .
- 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 .
- int light_cull_mask
The light will affect objects in the selected layers.
- light_energy
Default |
|
Setter | set_param(value) |
Getter | get_param() |
The light’s strength multiplier (this is not a physical unit). For OmniLight and , 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() |
- light_negative
Default |
|
Setter | set_negative(value) |
Getter | is_negative() |
If , the light’s effect is reversed, darkening areas and casting bright shadows.
- float light_size
Default |
|
Setter | set_param(value) |
Getter | get_param() |
The size of the light in Godot units. Only considered in baked lightmaps and only if is set to BAKE_ALL. Increasing this value will make the shadows appear blurrier. This can be used to simulate area lights to an extent.
- light_specular
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.
- shadow_color
Default |
|
Setter | set_shadow_color(value) |
Getter | get_shadow_color() |
The color of shadows cast by this light.
- float shadow_contact
Default |
|
Setter | set_param(value) |
Getter | get_param() |
Attempts to reduce gap by rendering screen-space contact shadows. This has a performance impact, especially at higher values.
Note: Contact shadows can look broken, so leaving this property to 0.0
is recommended.
- bool shadow_enabled
Default |
|
Setter | set_shadow(value) |
Getter | has_shadow() |
If true
, the light will cast shadows.
- shadow_reverse_cull_face
If , 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 GeometryInstance.SHADOW_CASTING_SETTING_DOUBLE_SIDED.
- float get_param ( param ) const
Sets the value of the specified Param parameter.