Skip to content

PointLight

Represents a light that emits from a single point in all directions.

A point light simulates a localized light source such as a bare lightbulb. Intensity follows physical inverse-square falloff, so intensity represents the light's brightness at a distance of one unit.

cpp
my_scene->Add(vglx::PointLight::Create({
  .color = 0xFFFFFF,
  .intensity = 25.0f,
  .range = 0.0f
}));

INFO

Derives from Light and inherits all public properties and methods.

Construction

Constructors


PointLight()

Constructs a point light.

cpp
PointLight::PointLight(const Parameters& params);
ParameterDescription
paramsInitialization parameters for constructing the light.

Factories preferred


PointLight::Create() std::unique_ptr<PointLight>

Creates an instance of PointLight with default parameters.

cpp
static std::unique_ptr<PointLight> PointLight::Create();

PointLight::Create() std::unique_ptr<PointLight>

Creates an instance of PointLight.

cpp
static std::unique_ptr<PointLight> PointLight::Create(const Parameters& params);
ParameterDescription
paramsInitialization parameters for constructing the light.

Types

PointLight::Parameters struct

Parameters for constructing a PointLight object.

ParameterDescription
color ColorLight color.
intensity floatLight intensity multiplier.
range floatMaximum range of influence. 0 = unbounded.
cast_shadow boolEnables shadow casting for this light.

Properties

cast_shadow bool

When true this light casts shadows.

cpp
bool cast_shadow {false};

range float

Maximum range of influence in world units.

Falloff is smoothly windowed to reach zero at this distance. A value of 0 disables the cutoff, leaving pure inverse-square falloff.

cpp
float range {0.0f};

shadow Shadow

Shadow configuration used when cast_shadow is enabled.

cpp
Shadow shadow {};

Functions

GetPower() float

Returns the light's luminous power in lumens.

Power is the total light emitted in all directions: , where is intensity in candela.

cpp
float PointLight::GetPower() const;

GetType() Light::Type virtual

Identifies this light as Light::Type::Point.

cpp
Type vglx::PointLight::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.

cpp
void PointLight::OnUpdate(float delta) override;
ParameterDescription
deltaTime 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 location using a spherical line geometry.

cpp
void PointLight::SetDebugMode(bool is_debug_mode) override;
ParameterDescription
is_debug_modetrue to enable debug mode; false to disable.

SetPower() void

Sets intensity from luminous power in lumens.

Useful for specifying brightness in familiar lightbulb terms, e.g. SetPower(800.0f) approximates a 60W incandescent bulb.

cpp
void PointLight::SetPower(float power);
ParameterDescription
powerLuminous power in lumens.

Released under the MIT License.