Unresolved Emitter¶
-
template<IsSpectral TSpectral>
class UnresolvedEmitter : public huira::UnresolvedObject<TSpectral>¶ Represents an unresolved isotropic point source with spectral power.
UnresolvedEmitter models a self-luminous object that emits light uniformly in all directions. The irradiance is computed using inverse square law based on the distance from the observer (assumed to be at the origin) and the total spectral power.
- Template Parameters:
TSpectral – The spectral representation type.
Public Functions
-
UnresolvedEmitter(const units::SpectralWatts<TSpectral> &spectral_power)¶
Constructs an UnresolvedEmitter from spectral power.
Creates an emitter with the specified spectral power distribution. The spectral power is validated to ensure all components are non-negative and finite.
- Parameters:
spectral_power – The spectral power in watts per wavelength bin.
- Throws:
std::runtime_error – if the spectral power contains invalid values.
-
UnresolvedEmitter(const units::Watt &power)¶
Constructs an UnresolvedEmitter from total power.
Creates an emitter with a total power value that is distributed across spectral bins proportionally to their wavelength widths.
- Parameters:
power – The total power in watts.
- Throws:
std::runtime_error – if the power is negative, NaN, or infinite.
-
virtual void resolve_irradiance(const Transform<float> &self_transform, const std::vector<LightInstance<TSpectral>> &lights) override¶
Resolves the spectral irradiance based on distance and spectral power.
Computes the irradiance at the observer (assumed to be at the origin) using the inverse square law. The irradiance is calculated as: \(E = \frac{\Phi}{4\pi d^2}\), where \(\Phi\) is the spectral power and \(d\) is the distance from the observer.
- Parameters:
self_transform – The world-space transform of the emitter.
lights – A vector of all light instances in the scene (unused).
-
void set_spectral_power(const units::SpectralWatts<TSpectral> &spectral_power)¶
Sets the spectral power of the emitter.
Updates the emitter’s spectral power distribution. The values are converted to SI units and validated to ensure all components are non-negative and finite.
- Parameters:
spectral_power – The new spectral power in watts per wavelength bin.
- Throws:
std::runtime_error – if the spectral power contains invalid values.
-
void set_spectral_power(const units::Watt &power)¶
Sets the total power of the emitter.
Updates the emitter’s power by distributing the total value proportionally across spectral bins based on their wavelength widths. The power is validated to ensure it is non-negative and finite.
- Parameters:
power – The total power in watts.
- Throws:
std::runtime_error – if the power is negative, NaN, or infinite.
-
inline virtual std::string type() const override¶
Get the object’s type string.
- Returns:
std::string Type
-
void set_irradiance(const units::SpectralWattsPerMeterSquared<TSpectral> &spectral_irradiance)¶
Sets the spectral irradiance of the unresolved object.
Updates the object’s irradiance value. All spectral components must be non-negative, as negative irradiance is physically meaningless.
- Parameters:
spectral_irradiance – The new spectral irradiance value in \(W \cdot m^{-2}\).
- Throws:
std::runtime_error – if any irradiance component is negative.
-
void set_irradiance(const units::WattsPerMeterSquared &irradiance)¶
Sets the total irradiance of the unresolved object.
Updates the object’s irradiance by converting a total irradiance value (in watts per square meter) to the spectral representation. The total irradiance must be non-negative, as negative values are physically meaningless.
- Parameters:
irradiance – The new total irradiance value in \(W \cdot m^{-2}\).
- Throws:
std::runtime_error – if the total irradiance is negative, NaN, or infinite.
-
virtual TSpectral get_irradiance(Time time) const¶
Returns the spectral irradiance at a given time.
This method provides a hook for future derived classes to implement time-varying irradiance. The default implementation assumes irradiance is constant once computed or set.
- Parameters:
time – The time at which to query irradiance (unused in default implementation).
- Returns:
The current spectral irradiance value.
-
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 Static Attributes
-
static std::uint64_t next_id_ = 0¶