DirectionalLight3D
Directional light from a distance, as from the Sun.
Directional light from a distance, as from the Sun.
A directional light is a type of Light3D node that models an infinite number of parallel rays covering the entire scene. It is used for lights with strong intensity that are located far away from the scene to model sunlight or moonlight.
Light is emitted in the -Z direction of the node's global basis. For an unrotated light, this means that the light is emitted forwards, illuminating the front side of a 3D model (see Vector3.Forward and Vector3.ModelFront). The position of the node is ignored; only the basis is used to determine light direction.
Declarations checked against C# SDK 1.0.0. Expand a name to see declarations and documentation.
Constructors1
DirectionalLight3DConstructor
public DirectionalLight3D();Properties9
DirectionalShadowBlendSplitsProperty
public bool DirectionalShadowBlendSplits { get; set; }If true, shadow detail is sacrificed in exchange for smoother transitions between splits. Enabling shadow blend splitting also has a moderate performance cost. This is ignored when DirectionalLight3D.DirectionalShadowMode is DirectionalLight3D.ShadowMode.Orthogonal.
DirectionalShadowFadeStartProperty
public float DirectionalShadowFadeStart { get; set; }Proportion of DirectionalLight3D.DirectionalShadowMaxDistance at which point the shadow starts to fade. At DirectionalLight3D.DirectionalShadowMaxDistance, the shadow will disappear. The default value is a balance between smooth fading and distant shadow visibility. If the camera moves fast and the DirectionalLight3D.DirectionalShadowMaxDistance is low, consider lowering DirectionalLight3D.DirectionalShadowFadeStart below 0.8 to make shadow transitions less noticeable. On the other hand, if you tuned DirectionalLight3D.DirectionalShadowMaxDistance to cover the entire scene, you can set DirectionalLight3D.DirectionalShadowFadeStart to 1.0 to prevent the shadow from fading in the distance (it will suddenly cut off instead).
DirectionalShadowMaxDistanceProperty
public float DirectionalShadowMaxDistance { get; set; }The maximum distance for shadow splits. Increasing this value will make directional shadows visible from further away, at the cost of lower overall shadow detail and performance (since more objects need to be included in the directional shadow rendering).
DirectionalShadowModeProperty
public DirectionalLight3D.ShadowMode DirectionalShadowMode { get; set; }The light's shadow rendering algorithm.
DirectionalShadowPancakeSizeProperty
public float DirectionalShadowPancakeSize { get; set; }Sets the size of the directional shadow pancake. The pancake offsets the start of the shadow's camera frustum to provide a higher effective depth resolution for the shadow. However, a high pancake size can cause artifacts in the shadows of large objects that are close to the edge of the frustum. Reducing the pancake size can help. Setting the size to 0 turns off the pancaking effect.
DirectionalShadowSplit1Property
public float DirectionalShadowSplit1 { get; set; }The distance from camera to shadow split 1. Relative to DirectionalLight3D.DirectionalShadowMaxDistance. Only used when DirectionalLight3D.DirectionalShadowMode is DirectionalLight3D.ShadowMode.Parallel2Splits or DirectionalLight3D.ShadowMode.Parallel4Splits.
DirectionalShadowSplit2Property
public float DirectionalShadowSplit2 { get; set; }The distance from shadow split 1 to split 2. Relative to DirectionalLight3D.DirectionalShadowMaxDistance. Only used when DirectionalLight3D.DirectionalShadowMode is DirectionalLight3D.ShadowMode.Parallel4Splits.
DirectionalShadowSplit3Property
public float DirectionalShadowSplit3 { get; set; }The distance from shadow split 2 to split 3. Relative to DirectionalLight3D.DirectionalShadowMaxDistance. Only used when DirectionalLight3D.DirectionalShadowMode is DirectionalLight3D.ShadowMode.Parallel4Splits.
SkyModeProperty
public DirectionalLight3D.SkyModeEnum SkyMode { get; set; }Directional-light participation: LightAndSky, LightOnly or SkyOnly. LightOnly excludes it from sky shader slots LIGHT0 through LIGHT3. SkyOnly retains sky participation without ordinary direct geometry lighting. A slot number is not a persistent light ID.
Methods6
GetShadowModeDirectionalLight3D.ShadowMode
public DirectionalLight3D.ShadowMode GetShadowMode();DirectionalLight3D.ShadowModeGetSkyModeDirectionalLight3D.SkyModeEnum
public DirectionalLight3D.SkyModeEnum GetSkyMode();Directional-light participation: LightAndSky, LightOnly or SkyOnly. LightOnly excludes it from sky shader slots LIGHT0 through LIGHT3. SkyOnly retains sky participation without ordinary direct geometry lighting. A slot number is not a persistent light ID.
DirectionalLight3D.SkyModeEnumAssigned SkyModeEnum.
IsBlendSplitsEnabledbool
public bool IsBlendSplitsEnabled();boolSetBlendSplitsvoid
public void SetBlendSplits(bool enabled);| Name | Type | Default |
|---|---|---|
enabled | bool | — |
SetShadowModevoid
public void SetShadowMode(DirectionalLight3D.ShadowMode mode);| Name | Type | Default |
|---|---|---|
mode | DirectionalLight3D.ShadowMode | — |
SetSkyModevoid
public void SetSkyMode(DirectionalLight3D.SkyModeEnum mode);Directional-light participation: LightAndSky, LightOnly or SkyOnly. LightOnly excludes it from sky shader slots LIGHT0 through LIGHT3. SkyOnly retains sky participation without ordinary direct geometry lighting. A slot number is not a persistent light ID.
| Name | Type | Default |
|---|---|---|
mode | DirectionalLight3D.SkyModeEnum | — |
modeLight/sky participation mode.
DirectionalLight3D.ShadowMode
| Value | Description |
|---|---|
Orthogonal = 0 | Renders the entire scene's shadow map from an orthogonal point of view. This is the fastest directional shadow mode. May result in blurrier shadows on close objects. |
Parallel2Splits = 1 | Splits the view frustum in 2 areas, each with its own shadow map. This shadow mode is a compromise between |
Parallel4Splits = 2 | Splits the view frustum in 4 areas, each with its own shadow map. This is the slowest directional shadow mode. |
DirectionalLight3D.SkyModeEnum
| Value | Description |
|---|---|
LightAndSky = 0 | Makes the light visible in both scene lighting and sky rendering. |
LightOnly = 1 | Makes the light visible in scene lighting only (including direct lighting and global illumination). When using this mode, the light will not be visible from sky shaders. |
SkyOnly = 2 | Makes the light visible to sky shaders only. When using this mode the light will not cast light into the scene (either through direct lighting or through global illumination), but can be accessed through sky shaders. This can be useful, for example, when you want to control sky effects without illuminating the scene (during a night cycle, for example). |