SpotLight
The light intensity diminishes both with distance and with the angle from the central axis of the cone. This type of light is commonly used to simulate focused sources such as flashlights or stage spotlights, where illumination is limited to a defined region and falls off outside of it.
auto spot_light = vglx::SpotLight::Create({
.color = 0xFFFFFF,
.intensity = 1.0f,
.angle = vglx::math::DegToRad(10.0f),
.penumbra = 0.3f,
.target = nullptr,
.attenuation = {
.base = 1.0f,
.linear = 0.0f,
.quadratic = 0.0f
}
});
When the target parameter is set to nullptr
the light points to (0, 0, 0).
INFO
Derives from Light and inherits all public properties and methods.
Construction
Constructors
SpotLight()
vglx::SpotLight::SpotLight(const Parameters ¶ms)
Parameter | Description |
---|---|
params | SpotLight::Parameters |
Constructs a SpotLight object.
Factories preferred
SpotLight::Create() auto
static auto vglx::SpotLight::Create(const Parameters ¶ms)
Parameter | Description |
---|---|
params | SpotLight::Parameters |
Creates a shared pointer to a SpotLight object.
Types
SpotLight::Parameters struct
Parameters for constructing a SpotLight object.
Name | Type | Description |
---|---|---|
angle | float | Cone angle (in radians) for spotlight cutoff. |
attenuation | Attenuation | Light attenuation properties. |
color | Color | Light color. |
intensity | float | Light intensity. |
penumbra | float | Softness of the spotlight edge. |
target | std::shared_ptr<Node> | Light target position. |
Properties
angle float
float angle
Angle, in radians, of the spotlight's cone.
attenuation Attenuation
Attenuation attenuation
Light attenuation properties.
penumbra float
float penumbra
Penumbra value controlling the softness of the spotlight's edge.
Node that the light is directed towards.
Functions
Vector3 vglx::SpotLight::Direction()
Returns the direction vector of the light. Calculates and returns the normalized direction in which the spotlight is pointing. The direction is determined based on the light's position and its target node.
GetType() LightType virtual
LightType vglx::SpotLight::GetType() const override
Returns light type.
OnUpdate() void virtual
void vglx::SpotLight::OnUpdate(float delta) override
Parameter | Description |
---|---|
delta | Time in seconds since the last update. |
Updates the light each frame.
SetDebugMode() void virtual
void vglx::SpotLight::SetDebugMode(bool is_debug_mode) override
Parameter | Description |
---|---|
is_debug_mode | True to enable debug mode, false to disable. |
Sets debug mode.