Mitsuba Renderer  0.5.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
mitsuba::Spectrum Struct Reference

Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range. More...

#include <mitsuba/core/spectrum.h>

+ Inheritance diagram for mitsuba::Spectrum:

Public Types

enum  EConversionIntent { EReflectance, EIlluminant }
 When converting from RGB reflectance values to discretized color spectra, the following `intent' flag can be provided to improve the results of this highly under-constrained problem. More...
 
typedef TSpectrum< Float,
SPECTRUM_SAMPLES > 
Parent
 
- Public Types inherited from mitsuba::TSpectrum< Float, SPECTRUM_SAMPLES >
typedef Float Scalar
 

Public Member Functions

 Spectrum ()
 Create a new spectral power distribution, but don't initialize the contents. More...
 
 Spectrum (const Parent &s)
 Construct from a TSpectrum instance. More...
 
template<typename AltScalar >
 Spectrum (const TSpectrum< AltScalar, SPECTRUM_SAMPLES > &v)
 Initialize with a TSpectrum data type based on a alternate representation. More...
 
 Spectrum (Float v)
 Create a new spectral power distribution with all samples set to the given value. More...
 
 Spectrum (Float value[SPECTRUM_SAMPLES])
 Copy a spectral power distribution. More...
 
 Spectrum (Stream *stream)
 Unserialize a spectral power distribution from a binary data stream. More...
 
Float eval (Float lambda) const
 Evaluate the SPD for the given wavelength in nanometers. More...
 
Float getLuminance () const
 Return the luminance in candelas. More...
 
void toXYZ (Float &x, Float &y, Float &z) const
 Convert from a spectral power distribution to XYZ tristimulus values. More...
 
void fromXYZ (Float x, Float y, Float z, EConversionIntent intent=EReflectance)
 Convert XYZ tristimulus into a plausible spectral reflectance or spectral power distribution. More...
 
void toIPT (Float &I, Float &P, Float &T) const
 Convert from a spectral power distribution to the perceptually uniform IPT color space by Ebner and Fairchild. More...
 
void fromIPT (Float I, Float P, Float T, EConversionIntent intent=EReflectance)
 Convert a color value represented in the IPT space into a plausible spectral reflectance or spectral power distribution. More...
 
void toLinearRGB (Float &r, Float &g, Float &b) const
 Convert to linear RGB. More...
 
void fromLinearRGB (Float r, Float g, Float b, EConversionIntent intent=EReflectance)
 Convert linear RGB colors into a plausible spectral power distribution. More...
 
void toSRGB (Float &r, Float &g, Float &b) const
 Convert to sRGB. More...
 
void fromSRGB (Float r, Float g, Float b)
 Convert sRGB color values into a plausible spectral power distribution. More...
 
void fromRGBE (const uint8_t rgbe[4], EConversionIntent intent=EIlluminant)
 Convert linear RGBE colors into a plausible spectral power distribution. More...
 
void toRGBE (uint8_t rgbe[4]) const
 Linear RGBE conversion based on Bruce Walter's and Greg Ward's code. More...
 
void fromContinuousSpectrum (const ContinuousSpectrum &smooth)
 Initialize with spectral values from a smooth spectrum representation. More...
 
bool operator== (const Spectrum &val) const
 Equality test. More...
 
bool operator!= (const Spectrum &val) const
 Inequality test. More...
 
std::string toString () const
 Return a string representation. More...
 
- Public Member Functions inherited from mitsuba::TSpectrum< Float, SPECTRUM_SAMPLES >
 TSpectrum ()
 Create a new spectral power distribution, but don't initialize the contents. More...
 
 TSpectrum (Scalar v)
 Create a new spectral power distribution with all samples set to the given value. More...
 
 TSpectrum (Scalar spec[N])
 Copy a spectral power distribution. More...
 
 TSpectrum (Stream *stream)
 Unserialize a spectral power distribution from a binary data stream. More...
 
 TSpectrum (const TSpectrum< AltScalar, N > &v)
 Initialize with a TSpectrum data type based on a alternate representation. More...
 
TSpectrum operator+ (const TSpectrum &spec) const
 Add two spectral power distributions. More...
 
TSpectrumoperator+= (const TSpectrum &spec)
 Add a spectral power distribution to this instance. More...
 
TSpectrum operator- (const TSpectrum &spec) const
 Subtract a spectral power distribution. More...
 
TSpectrum operator- () const
 Negate. More...
 
TSpectrumoperator-= (const TSpectrum &spec)
 Subtract a spectral power distribution from this instance. More...
 
TSpectrum operator* (Scalar f) const
 Multiply by a scalar. More...
 
TSpectrum operator* (const TSpectrum &spec) const
 Perform a component-wise multiplication by another spectrum. More...
 
TSpectrumoperator*= (Scalar f)
 Multiply by a scalar. More...
 
TSpectrumoperator*= (const TSpectrum &spec)
 Perform a component-wise multiplication by another spectrum. More...
 
TSpectrumoperator/= (const TSpectrum &spec)
 Perform a component-wise division by another spectrum. More...
 
TSpectrumoperator/= (Scalar f)
 Divide by a scalar. More...
 
TSpectrum operator/ (const TSpectrum &spec) const
 Perform a component-wise division by another spectrum. More...
 
TSpectrum operator/ (Scalar f) const
 Divide by a scalar. More...
 
bool operator== (const TSpectrum &spec) const
 Equality test. More...
 
bool operator!= (const TSpectrum &spec) const
 Inequality test. More...
 
bool isNaN () const
 Check for NaNs. More...
 
bool isValid () const
 Returns whether the spectrum only contains valid (non-NaN, nonnegative) samples. More...
 
void addWeighted (Scalar weight, const TSpectrum &spec)
 Multiply-accumulate operation, adds weight * spec. More...
 
Scalar average () const
 Return the average over all wavelengths. More...
 
TSpectrum abs () const
 Component-wise absolute value. More...
 
TSpectrum sqrt () const
 Component-wise square root. More...
 
TSpectrum safe_sqrt () const
 Component-wise square root. More...
 
TSpectrum log () const
 Component-wise logarithm. More...
 
TSpectrum exp () const
 Component-wise exponentation. More...
 
TSpectrum pow (Scalar f) const
 Component-wise power. More...
 
void clampNegative ()
 Clamp negative values. More...
 
Scalar max () const
 Return the highest-valued spectral sample. More...
 
Scalar min () const
 Return the lowest-valued spectral sample. More...
 
Scalaroperator[] (int entry)
 Indexing operator. More...
 
Scalar operator[] (int entry) const
 Indexing operator. More...
 
bool isZero () const
 Check if this spectrum is zero at all wavelengths. More...
 
void serialize (Stream *stream) const
 Serialize this spectrum to a stream. More...
 
std::string toString () const
 

Static Public Member Functions

static std::pair< Float, FloatgetBinCoverage (size_t index)
 Return the wavelength range covered by a spectral bin. More...
 
static const SpectrumgetD65 ()
 Return a spectral color distribution of the D65 white point (with unit luminance) More...
 
static void staticInitialization ()
 Static initialization (should be called once during the application's initialization phase) More...
 
static void staticShutdown ()
 

Static Protected Attributes

static Float m_wavelengths [SPECTRUM_SAMPLES+1]
 Configured wavelengths bins in nanometers. More...
 
static Spectrum CIE_D65
 Pre-integrated D65 illuminant. More...
 
Pre-integrated CIE 1931 XYZ color matching functions.
static Spectrum CIE_X
 
static Spectrum CIE_Y
 
static Spectrum CIE_Z
 
static Float CIE_normalization
 
Pre-integrated Smits-style RGB to Spectrum

conversion spectra, data by Karl vom Berge

static Spectrum rgbRefl2SpecWhite
 
static Spectrum rgbRefl2SpecCyan
 
static Spectrum rgbRefl2SpecMagenta
 
static Spectrum rgbRefl2SpecYellow
 
static Spectrum rgbRefl2SpecRed
 
static Spectrum rgbRefl2SpecGreen
 
static Spectrum rgbRefl2SpecBlue
 
static Spectrum rgbIllum2SpecWhite
 
static Spectrum rgbIllum2SpecCyan
 
static Spectrum rgbIllum2SpecMagenta
 
static Spectrum rgbIllum2SpecYellow
 
static Spectrum rgbIllum2SpecRed
 
static Spectrum rgbIllum2SpecGreen
 
static Spectrum rgbIllum2SpecBlue
 

Additional Inherited Members

- Static Public Attributes inherited from mitsuba::TSpectrum< Float, SPECTRUM_SAMPLES >
static const int dim
 Number of dimensions. More...
 
- Protected Attributes inherited from mitsuba::TSpectrum< Float, SPECTRUM_SAMPLES >
Scalar s [N]
 

Detailed Description

Discrete spectral power distribution based on a number of wavelength bins over the 360-830 nm range.

This class defines a vector-like data type that can be used for computations involving radiance.

When configured for spectral rendering (i.e. when the compile-time flag SPECTRUM_SAMPLES is set to a value != 3), the implementation discretizes the visible spectrum of light into a set of intervals, where the distribution within each bin is modeled as being uniform.

When SPECTRUM_SAMPLES == 3, the class reverts to a simple linear RGB-based internal representation.

The implementation of this class is based on PBRT.

Member Typedef Documentation

typedef TSpectrum<Float, SPECTRUM_SAMPLES> mitsuba::Spectrum::Parent

Member Enumeration Documentation

When converting from RGB reflectance values to discretized color spectra, the following `intent' flag can be provided to improve the results of this highly under-constrained problem.

Enumerator
EReflectance 

Unitless reflectance data is converted.

EIlluminant 

Radiance-valued illumination data is converted.

Constructor & Destructor Documentation

mitsuba::Spectrum::Spectrum ( )
inline

Create a new spectral power distribution, but don't initialize the contents.

mitsuba::Spectrum::Spectrum ( const Parent s)
inline

Construct from a TSpectrum instance.

template<typename AltScalar >
mitsuba::Spectrum::Spectrum ( const TSpectrum< AltScalar, SPECTRUM_SAMPLES > &  v)
inlineexplicit

Initialize with a TSpectrum data type based on a alternate representation.

mitsuba::Spectrum::Spectrum ( Float  v)
inlineexplicit

Create a new spectral power distribution with all samples set to the given value.

mitsuba::Spectrum::Spectrum ( Float  value[SPECTRUM_SAMPLES])
inlineexplicit

Copy a spectral power distribution.

mitsuba::Spectrum::Spectrum ( Stream stream)
inlineexplicit

Unserialize a spectral power distribution from a binary data stream.

Member Function Documentation

Float mitsuba::Spectrum::eval ( Float  lambda) const

Evaluate the SPD for the given wavelength in nanometers.

void mitsuba::Spectrum::fromContinuousSpectrum ( const ContinuousSpectrum smooth)

Initialize with spectral values from a smooth spectrum representation.

void mitsuba::Spectrum::fromIPT ( Float  I,
Float  P,
Float  T,
EConversionIntent  intent = EReflectance 
)

Convert a color value represented in the IPT space into a plausible spectral reflectance or spectral power distribution.

The EConversionIntent parameter can be used to provide more information on how to solve this highly under-constrained problem. The default is EReflectance.

void mitsuba::Spectrum::fromLinearRGB ( Float  r,
Float  g,
Float  b,
EConversionIntent  intent = EReflectance 
)

Convert linear RGB colors into a plausible spectral power distribution.

The EConversionIntent parameter can be used to provide more information on how to solve this highly under-constrained problem. The default is EReflectance.

void mitsuba::Spectrum::fromRGBE ( const uint8_t  rgbe[4],
EConversionIntent  intent = EIlluminant 
)

Convert linear RGBE colors into a plausible spectral power distribution.

Based on code by Bruce Walter and Greg ward.

The EConversionIntent parameter can be used to provide more information on how to solve this highly under-constrained problem. For RGBE values, the default is EIlluminant.

void mitsuba::Spectrum::fromSRGB ( Float  r,
Float  g,
Float  b 
)

Convert sRGB color values into a plausible spectral power distribution.

Note that compared to fromLinearRGB, no intent parameter is available. For sRGB colors, it is assumed that the intent is always EReflectance.

void mitsuba::Spectrum::fromXYZ ( Float  x,
Float  y,
Float  z,
EConversionIntent  intent = EReflectance 
)

Convert XYZ tristimulus into a plausible spectral reflectance or spectral power distribution.

The EConversionIntent parameter can be used to provide more information on how to solve this highly under-constrained problem. The default is EReflectance.

static std::pair<Float, Float> mitsuba::Spectrum::getBinCoverage ( size_t  index)
static

Return the wavelength range covered by a spectral bin.

static const Spectrum& mitsuba::Spectrum::getD65 ( )
inlinestatic

Return a spectral color distribution of the D65 white point (with unit luminance)

Float mitsuba::Spectrum::getLuminance ( ) const

Return the luminance in candelas.

bool mitsuba::Spectrum::operator!= ( const Spectrum val) const
inline

Inequality test.

bool mitsuba::Spectrum::operator== ( const Spectrum val) const
inline

Equality test.

static void mitsuba::Spectrum::staticInitialization ( )
static

Static initialization (should be called once during the application's initialization phase)

This function is responsible for choosing the wavelengths that will be used during rendering. It also pre-integrates the CIE matching curves so that sampled spectra can efficiently be converted to XYZ tristimulus values. Finally, it sets up pre-integrated color spectra for conversions from linear RGB to plausible spectral color distributions.

static void mitsuba::Spectrum::staticShutdown ( )
static
void mitsuba::Spectrum::toIPT ( Float I,
Float P,
Float T 
) const

Convert from a spectral power distribution to the perceptually uniform IPT color space by Ebner and Fairchild.

This is useful e.g. for computing color differences. I encodes intensity, P (protan) roughly encodes red-green color opponency, and T (tritan) encodes blue-red color opponency. For normalized input, the range of attainable values is given by \( I\in $[0,1], P,T\in [-1,1]\).

In the Python API, this function returns a 3-tuple with the result of the operation.

void mitsuba::Spectrum::toLinearRGB ( Float r,
Float g,
Float b 
) const

Convert to linear RGB.

In the Python API, this function returns a 3-tuple with the result of the operation.

void mitsuba::Spectrum::toRGBE ( uint8_t  rgbe[4]) const

Linear RGBE conversion based on Bruce Walter's and Greg Ward's code.

void mitsuba::Spectrum::toSRGB ( Float r,
Float g,
Float b 
) const

Convert to sRGB.

In the Python API, this function returns a 3-tuple with the result of the operation.

std::string mitsuba::Spectrum::toString ( ) const

Return a string representation.

void mitsuba::Spectrum::toXYZ ( Float x,
Float y,
Float z 
) const

Convert from a spectral power distribution to XYZ tristimulus values.

In the Python API, this function returns a 3-tuple with the result of the operation.

Member Data Documentation

Spectrum mitsuba::Spectrum::CIE_D65
staticprotected

Pre-integrated D65 illuminant.

Float mitsuba::Spectrum::CIE_normalization
staticprotected
Spectrum mitsuba::Spectrum::CIE_X
staticprotected
Spectrum mitsuba::Spectrum::CIE_Y
staticprotected
Spectrum mitsuba::Spectrum::CIE_Z
staticprotected
Float mitsuba::Spectrum::m_wavelengths[SPECTRUM_SAMPLES+1]
staticprotected

Configured wavelengths bins in nanometers.

Spectrum mitsuba::Spectrum::rgbIllum2SpecBlue
staticprotected
Spectrum mitsuba::Spectrum::rgbIllum2SpecCyan
staticprotected
Spectrum mitsuba::Spectrum::rgbIllum2SpecGreen
staticprotected
Spectrum mitsuba::Spectrum::rgbIllum2SpecMagenta
staticprotected
Spectrum mitsuba::Spectrum::rgbIllum2SpecRed
staticprotected
Spectrum mitsuba::Spectrum::rgbIllum2SpecWhite
staticprotected
Spectrum mitsuba::Spectrum::rgbIllum2SpecYellow
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecBlue
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecCyan
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecGreen
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecMagenta
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecRed
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecWhite
staticprotected
Spectrum mitsuba::Spectrum::rgbRefl2SpecYellow
staticprotected

The documentation for this struct was generated from the following file: