Class Light3D
- Namespace
- Godot
- Assembly
- GodotSharp.dll
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.
public class Light3D : VisualInstance3D, IDisposable
- Inheritance
-
Light3D
- Implements
- Derived
- Inherited Members
Properties
DistanceFadeBegin
The distance from the camera at which the light begins to fade away (in 3D units).
Note: Only effective for OmniLight3D and SpotLight3D.
public float DistanceFadeBegin { get; set; }
Property Value
DistanceFadeEnabled
If true
, the light will smoothly fade away when far from the active Camera3D starting at DistanceFadeBegin. This acts as a form of level of detail (LOD). The light will fade out over DistanceFadeBegin + DistanceFadeLength, 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.
public bool DistanceFadeEnabled { get; set; }
Property Value
DistanceFadeLength
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.
public float DistanceFadeLength { get; set; }
Property Value
DistanceFadeShadow
The distance from the camera at which the light's shadow cuts off (in 3D units). Set this to a value lower than DistanceFadeBegin + DistanceFadeLength 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 ShadowEnabled is true
.
public float DistanceFadeShadow { get; set; }
Property Value
EditorOnly
If true
, the light only appears in the editor and will not be visible at runtime. If true
, the light will never be baked in LightmapGI regardless of its LightBakeMode.
public bool EditorOnly { get; set; }
Property Value
LightAngularDistance
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: LightAngularDistance is not affected by 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.
public float LightAngularDistance { get; set; }
Property Value
LightBakeMode
The light's bake mode. This will affect the global illumination techniques that have an effect on the light's rendering. See Light3D.BakeMode.
Note: Meshes' global illumination mode will also affect the global illumination rendering. See GIMode.
public Light3D.BakeMode LightBakeMode { get; set; }
Property Value
LightColor
The light's color. An overbright color can be used to achieve a result equivalent to increasing the light's LightEnergy.
public Color LightColor { get; set; }
Property Value
LightCullMask
The light will affect objects in the selected layers.
public uint LightCullMask { get; set; }
Property Value
LightEnergy
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.
public float LightEnergy { get; set; }
Property Value
LightIndirectEnergy
Secondary multiplier used with indirect light (light bounces). Used with VoxelGI and SDFGI (see SdfgiEnabled).
Note: This property is ignored if LightEnergy is equal to 0.0
, as the light won't be present at all in the GI shader.
public float LightIndirectEnergy { get; set; }
Property Value
LightIntensityLumens
Used by positional lights (OmniLight3D and SpotLight3D) when ProjectSettings.rendering/lights_and_shadows/use_physical_light_units
is true
. 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.
For SpotLight3Ds, 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.
public float LightIntensityLumens { get; set; }
Property Value
LightIntensityLux
Used by DirectionalLight3Ds when ProjectSettings.rendering/lights_and_shadows/use_physical_light_units
is true
. 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.
public float LightIntensityLux { get; set; }
Property Value
LightNegative
If true
, the light's effect is reversed, darkening areas and casting bright shadows.
public bool LightNegative { get; set; }
Property Value
LightProjector
Texture2D projected by light. ShadowEnabled 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: Unlike BaseMaterial3D whose filter mode can be adjusted on a per-material basis, the filter mode for light projector textures is set globally with ProjectSettings.rendering/textures/light_projectors/filter
.
Note: Light projector textures are only supported in the Forward+ and Mobile rendering methods, not Compatibility.
public Texture2D LightProjector { get; set; }
Property Value
LightSize
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 (also called percentage-closer soft shadows, or PCSS). This can be used to simulate area lights to an extent. Increasing this value above 0.0
for lights with shadows enabled will have a noticeable performance cost due to PCSS.
Note: LightSize is not affected by 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.
public float LightSize { get; set; }
Property Value
LightSpecular
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.
public float LightSpecular { get; set; }
Property Value
LightTemperature
Sets the color temperature of the light source, measured in Kelvin. This is used to calculate a correlated color temperature which tints the LightColor.
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.
public float LightTemperature { get; set; }
Property Value
LightVolumetricFogEnergy
Secondary multiplier multiplied with LightEnergy then used with the Environment's volumetric fog (if enabled). If set to 0.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 have LightVolumetricFogEnergy set to 0.0
unless VolumetricFogTemporalReprojectionEnabled is disabled (or unless the reprojection amount is significantly lowered).
public float LightVolumetricFogEnergy { get; set; }
Property Value
ShadowBias
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.
public float ShadowBias { get; set; }
Property Value
ShadowBlur
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.
public float ShadowBlur { get; set; }
Property Value
ShadowEnabled
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 DistanceFadeEnabled to hide the light when far away from the Camera3D.
public bool ShadowEnabled { get; set; }
Property Value
ShadowNormalBias
Offsets the lookup into the shadow map by the object's normal. This can be used to reduce self-shadowing artifacts without using ShadowBias. In practice, this value should be tweaked along with ShadowBias to reduce artifacts as much as possible.
public float ShadowNormalBias { get; set; }
Property Value
ShadowOpacity
The opacity to use when rendering the light's shadow map. Values lower than 1.0
make the light appear through shadows. This can be used to fake global illumination at a low performance cost.
public float ShadowOpacity { get; set; }
Property Value
ShadowReverseCullFace
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 DoubleSided.
public bool ShadowReverseCullFace { get; set; }
Property Value
ShadowTransmittanceBias
public float ShadowTransmittanceBias { get; set; }
Property Value
Methods
GetCorrelatedColor()
Returns the Color of an idealized blackbody at the given LightTemperature. This value is calculated internally based on the LightTemperature. This Color is multiplied by LightColor before being sent to the RenderingServer.
public Color GetCorrelatedColor()
Returns
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.