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.
Checking the stable version of the documentation...
SpotLight3D¶
继承: Light3D < VisualInstance3D < Node3D < Node < Object
聚光灯,如反射器聚光灯或灯笼。
描述¶
聚光灯是一种 Light3D 节点,向指定的方向发出圆锥形的灯光。光线会随距离增大而衰减。衰减可以通过修改 Light3D 的能量、半径、衰减参数进行控制。
注意:使用 Mobile 渲染方法时,单个网格资源只能用到 8 盏聚光灯。尝试对单个网格资源使用超过 8 盏聚光灯会导致聚光灯在相机移动时产生闪烁。使用 Compatibility 渲染方法时,单个网格资源默认只能用到 8 盏聚光灯,但可以通过调整 ProjectSettings.rendering/limits/opengl/max_lights_per_object 增加。
注意:使用 Mobile 或 Compatibility 渲染方法时,聚光灯只能影响可见 AABB 与灯光 AABB 相交的网格。如果使用了着色器将网格进行了变形,超出了 AABB 的范围,则必须将该网格的 GeometryInstance3D.extra_cull_margin 增大。否则灯光在该网格上可能不可见。
教程¶
属性¶
shadow_bias |
|
|
shadow_normal_bias |
|
|
|
||
|
||
|
||
|
属性说明¶
float spot_angle = 45.0
聚光灯的角度,单位为度。
注意:spot_angle 不受 Node3D.scale 的影响(无论是该灯光的缩放还是其父节点的缩放)。
float spot_angle_attenuation = 1.0
聚光灯的角度衰减曲线。另见 spot_attenuation。
float spot_attenuation = 1.0
聚光灯的光照能量(下降)衰减曲线。在检查器中右键单击曲线会提供一些预设。允许零和负数,但可能产生异常效果。另见 spot_angle_attenuation。
注意:如果 spot_attenuation 值很高(一般大于 10),将灯光的 spot_range 调大去进行补偿会对性能产生负面影响。这是因为剔除的机会会变少,从而增加在着色上的消耗(因为在亮度相同的前提下,灯光会覆盖屏幕上的更多像素)。为了提升性能,请使用尽可能低的 spot_attenuation 值来达成想要的显示效果。
float spot_range = 5.0
聚光灯可以达到的最大范围。请注意,根据使用的 spot_attenuation,有效照明区域可能看起来更小。无论 spot_attenuation 为何值,光都不会到达此范围之外的任何东西。
注意:spot_angle 不受 Node3D.scale 的影响(无论是该灯光的缩放还是其父节点的缩放)。