Attention: Here be dragons

This is the latest (unstable) version of this documentation, which may document features not available in or compatible with released stable versions of Godot.

DirectionalLight3D

繼承: Light3D < VisualInstance3D < Node3D < Node < Object

來自遠處的平行光,如太陽光。

說明

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.MODEL_FRONT). The position of the node is ignored; only the basis is used to determine light direction.

教學

屬性

bool

directional_shadow_blend_splits

false

float

directional_shadow_fade_start

0.8

float

directional_shadow_max_distance

100.0

ShadowMode

directional_shadow_mode

2

float

directional_shadow_pancake_size

20.0

float

directional_shadow_split_1

0.1

float

directional_shadow_split_2

0.2

float

directional_shadow_split_3

0.5

SkyMode

sky_mode

0


列舉

enum ShadowMode: 🔗

ShadowMode SHADOW_ORTHOGONAL = 0

從正交的角度算繪整個場景的陰影圖。這是最快的定向陰影模式。可能會導致近距離物體的陰影更模糊。

ShadowMode SHADOW_PARALLEL_2_SPLITS = 1

將視錐體分成2個區域,每個區域都有自己的陰影貼圖。這種陰影模式是 SHADOW_ORTHOGONALSHADOW_PARALLEL_4_SPLITS 在性能上的折衷。

ShadowMode SHADOW_PARALLEL_4_SPLITS = 2

將視錐體分成 4 個區域,每個區域都有自己的陰影貼圖。這是最慢的定向陰影模式。


enum SkyMode: 🔗

SkyMode SKY_MODE_LIGHT_AND_SKY = 0

使燈光在場景照明和天空算繪中都可見。

SkyMode SKY_MODE_LIGHT_ONLY = 1

使燈光僅在場景照明中可見(包括直接照明和全域照明)。使用此模式時,天空著色器看不到此燈光。

SkyMode SKY_MODE_SKY_ONLY = 2

使燈光僅對天空著色器可見。使用此模式時,燈光不會將燈光投射到場景中(通過直接照明或通過全域照明),但可以通過天空著色器存取。例如,當你想要控制天空效果而不照亮場景時(例如,在夜間迴圈期間),這可能很有用。


屬性說明

bool directional_shadow_blend_splits = false 🔗

  • void set_blend_splits(value: bool)

  • bool is_blend_splits_enabled()

如果為 true,會犧牲陰影的細節,換取分割區域之間更平滑的過渡。啟用陰影混合分割同時也會帶來一些性能消耗。當 directional_shadow_modeSHADOW_ORTHOGONAL 時會被忽略。


float directional_shadow_fade_start = 0.8 🔗

陰影開始消失時,directional_shadow_max_distance 的比例。在 directional_shadow_max_distance 處,陰影會消失。預設值是平滑淡化和遠處陰影可見性之間的平衡。如果相機移動較快且 directional_shadow_max_distance 較低,請考慮將 directional_shadow_fade_start 降低到 0.8 以下,以使陰影過渡不那麼明顯。另一方面,如果調整了 directional_shadow_max_distance 來覆蓋整個場景,可以將 directional_shadow_fade_start 設定為 1.0,以防止陰影在遠處逐漸淡化(它將會突然切斷 )。


float directional_shadow_max_distance = 100.0 🔗

陰影分割的最大距離。將這個值增大會讓定向陰影在更遠處可見,代價是整體的陰影細節降低和性能(因為算繪定向陰影時需要包含更多的物體)。


ShadowMode directional_shadow_mode = 2 🔗

The light's shadow rendering algorithm.


float directional_shadow_pancake_size = 20.0 🔗

設定定向陰影斑點的大小。 斑點偏移了陰影的相機視錐體的起點,為陰影提供更高的有效深度解析度。但是,較大的斑點尺寸會導致靠近視錐體邊緣的大型物體的陰影出現偽影。減少斑點的大小會有所幫助。將大小設定為 0 會關閉斑點效果。


float directional_shadow_split_1 = 0.1 🔗

相機到陰影分割 1 的距離。相對於 directional_shadow_max_distance。只有當 directional_shadow_modeSHADOW_PARALLEL_2_SPLITSSHADOW_PARALLEL_4_SPLITS 時才使用。


float directional_shadow_split_2 = 0.2 🔗

從陰影分割 1 到陰影分割 2 的距離。相對於 directional_shadow_max_distance。僅在 directional_shadow_modeSHADOW_PARALLEL_4_SPLITS 時使用。


float directional_shadow_split_3 = 0.5 🔗

從陰影分割 2 到陰影分割 3 的距離。相對於 directional_shadow_max_distance。只有當 directional_shadow_modeSHADOW_PARALLEL_4_SPLITS 時才使用。


SkyMode sky_mode = 0 🔗

Whether this DirectionalLight3D is visible in the sky, in the scene, or both in the sky and in the scene.