DirectionalLight
A directional light simulates an infinitely distant light source, such as sunlight. All light rays are considered parallel, and the light has no position in space, only direction. This makes it ideal for large-scale illumination like outdoor or scene-wide lighting.
When the target parameter is set to nullptr, the light will point toward the world origin.
auto directional = vglx::DirectionalLight::Create({
.color = 0xFFFFFF,
.intensity = 1.0f,
.target = nullptr
});INFO
Derives from Light and inherits all public properties and methods.
Construction
Constructors
DirectionalLight()
Constructs a directional light.
DirectionalLight::DirectionalLight(const Parameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters for constructing the light. |
Factories preferred
DirectionalLight::Create() auto
Creates a shared instance of DirectionalLight.
static auto DirectionalLight::Create(const Parameters& params);| Parameter | Description |
|---|---|
| params | Initialization parameters for constructing the light. |
Types
DirectionalLight::Parameters struct
Parameters for constructing a DirectionalLight object.
| Parameter | Description |
|---|---|
| color Color | Light color. |
| intensity float | Light intensity multiplier. |
| target std::shared_ptr<Node> | Node the light is directed toward. |
Properties
Node that the light is oriented toward.
std::shared_ptr<Node> target {};Functions
Returns the normalized direction vector of the light.
The direction is derived from the light’s position and its target node. If no target is set, the light will point toward the origin.
Vector3 DirectionalLight::Direction();GetType() Light::Type virtual
Identifies this light as Light::Type::DirectionalLight.
Type vglx::DirectionalLight::GetType() const override;OnUpdate() void virtual
Called once per frame to update the light state.
Currently used to update the debug geometry when debug mode is enabled.
void DirectionalLight::OnUpdate(float delta) override;| Parameter | Description |
|---|---|
| delta | Time in seconds since the last frame. |
SetDebugMode() void virtual
Enables or disables debug visualization for this light.
When enabled, the renderer will visualize the light’s direction using a line and a unit plane facing the target.
void DirectionalLight::SetDebugMode(bool is_debug_mode) override;| Parameter | Description |
|---|---|
| is_debug_mode | true to enable debug mode; false to disable. |