Point Light

template<IsSpectral TSpectral>
class PointLight : public huira::Light<TSpectral>

A point light source that emits light uniformly in all directions.

Point lights are infinitesimally small light sources located at a single point in space. The irradiance falls off with the inverse square of the distance.

Template Parameters:

TSpectral – The spectral representation type.

Public Functions

PointLight(const units::SpectralWatts<TSpectral> &spectral_power)

Constructs a PointLight from spectral power.

The irradiance is computed by dividing the total spectral power by \(4\pi\), representing uniform emission over a sphere. The input must be real and non-negative.

Parameters:

spectral_power – The total spectral power emitted by the light source.

PointLight(const units::Watt &power)

Constructs a PointLight from total spectral power.

The irradiance is computed by dividing the total spectral power by \(4\pi\), representing uniform emission over a sphere, and that irradiance is then spread proportionally across all spectral bins. The input must be real and non-negative.

Parameters:

power – The total spectral power emitted by the light source.

PointLight(const PointLight&) = delete
PointLight &operator=(const PointLight&) = delete
virtual std::optional<LightSample<TSpectral>> sample_li(const Interaction<TSpectral> &ref, const Transform<float> &light_to_world, const Sampler<float> &sampler) const override

Samples the incident radiance from this point light.

Computes the light contribution at a reference point by calculating the direction to the light, distance, and incident radiance based on inverse square falloff.

Parameters:
  • ref – The surface interaction point being illuminated.

  • light_to_worldTransform from light’s local space to world space.

  • sampler – Random sampler (unused for point lights).

Returns:

A LightSample containing direction, radiance, distance, and PDF, or std::nullopt if the reference point coincides with the light.

virtual float pdf_li(const Interaction<TSpectral> &ref, const Transform<float> &light_to_world, const Vec3<float> &wi) const override

Returns the probability density for sampling the given direction.

For point lights, the PDF is always 1.0 since there is only one possible direction to the light from any given point.

Parameters:
  • ref – The surface interaction point.

  • light_to_worldTransform from light’s local space to world space.

  • wi – The incident direction being queried.

Returns:

Always returns 1.0 for point lights.

virtual TSpectral irradiance_at(const Vec3<float> &position, const Transform<float> &light_to_world) const override

Computes the spectral irradiance at a given position.

Calculates the spectral irradiance based on the distance from the light to the position, using inverse square law falloff. The value is returned in SI units: \(W \cdot m^{-2}\).

Parameters:
  • position – The world-space position to evaluate irradiance at.

  • light_to_worldTransform from light’s local space to world space.

Returns:

The spectral irradiance at the given position.

inline virtual LightType get_type() const override
inline virtual std::string type() const override

Get the object’s type string.

Returns:

std::string Type

void set_spectral_power(const units::SpectralWatts<TSpectral> &spectral_power)

Sets the total spectral power emitted by the point light.

Updates the light’s emitted irradiance by dividing the total spectral power over \(4\pi\), representing uniform emission in all directions. All components must be real and non-negative.

Parameters:

spectral_power – The new total spectral power value.

Throws:

std::runtime_error – if any spectral power component is invalid.

void set_spectral_power(const units::Watt &power)

Sets the total spectral power emitted by the point light.

Sets the total emitted spectral power (in all directions) for the point light. The value is divided by \(4\pi\) to compute the irradiance, representing uniform emission over a sphere. This irradiance is then spread proportionally across all spectral bins. The input must be real and non-negative.

Parameters:

power – The total spectral power to set (must be real and non-negative).

Throws:

std::runtime_error – if the power is invalid (negative, NaN, or infinite).

inline virtual std::uint64_t id() const override

Get the object’s unique ID.

Returns:

std::uint64_t ID

inline bool is_scene_owned() const

Check if the object is owned by the scene.

Returns:

bool True if owned

inline void set_scene_owned(bool owned)

Set scene ownership flag.

Parameters:

owned – True if owned

inline std::string name() const

Get the object’s name.

Returns:

std::string Name

inline virtual std::string get_info() const

Get a descriptive info string for the object.

Returns:

std::string Info string

Protected Attributes

std::uint64_t id_ = 0

Protected Static Attributes

static std::uint64_t next_id_ = 0