Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

DirectionalLight2D

继承: Light2D < Node2D < CanvasItem < Node < Object

来自远处的 2D 平行光。

描述

平行光是一种 Light2D 节点,模拟覆盖整个场景的无数平行光线。可用于远离场景的强光(例如:模拟日光或月光)。

注意:DirectionalLight2D 不支持灯光剔除遮罩(但支持阴影剔除遮罩)。它会忽略 2D 节点的 CanvasItem.light_mask,始终点亮 2D 节点。

教程

属性

float

height

0.0

float

max_distance

10000.0


属性说明

float height = 0.0

  • void set_height ( float value )

  • float get_height ( )

灯光的高度。用于 2D 法线贴图。范围从 0(平行于平面)到 1(垂直于平面)。


float max_distance = 10000.0

  • void set_max_distance ( float value )

  • float get_max_distance ( )

对象在其阴影被剔除前与相机中心的最大距离(单位:像素)。降低这个值可以防止位于相机外部的对象投射阴影(同时还可以提高性能)。Camera2D.zoom 不被 max_distance 考虑在内,这意味着在较高的缩放值下,当缩放到一个给定的点时,阴影会更快地淡出。