19 #if !defined(__NORI_COLOR_H)
20 #define __NORI_COLOR_H
22 #include <nori/common.h>
31 typedef Eigen::Array3f Base;
34 Color3f(
float value = 0.f) : Base(value, value, value) { }
40 template <
typename Derived>
Color3f(
const Eigen::ArrayBase<Derived>& p)
45 this->Base::operator=(p);
50 float &
r() {
return x(); }
52 const float &
r()
const {
return x(); }
54 float &
g() {
return y(); }
56 const float &
g()
const {
return y(); }
58 float &
b() {
return z(); }
60 const float &
b()
const {
return z(); }
64 std::max(
g(), 0.0f), std::max(
b(), 0.0f)); }
80 return tfm::format(
"[%f, %f, %f]", coeff(0), coeff(1), coeff(2));
91 typedef Eigen::Array4f Base;
94 Color4f() : Base(0.0f, 0.0f, 0.0f, 0.0f) { }
100 Color4f(
float r,
float g,
float b,
float w) : Base(r, g, b, w) { }
103 template <
typename Derived>
Color4f(
const Eigen::ArrayBase<Derived>& p)
108 this->Base::operator=(p);
115 return head<3>() / w();
122 return tfm::format(
"[%f, %f, %f, %f]", coeff(0), coeff(1), coeff(2), coeff(3));
Represents a linear RGB color value.
bool isValid() const
Check if the color vector contains a NaN/Inf/negative value.
std::string toString() const
Return a human-readable string summary.
float & g()
Return a reference to the green channel.
const float & r() const
Return a reference to the red channel (const version)
const float & b() const
Return a reference to the blue channel (const version)
float getLuminance() const
Return the associated luminance.
Color3f(float value=0.f)
Initialize the color vector with a uniform value.
Color3f toLinearRGB() const
Convert from sRGB to linear RGB.
float & b()
Return a reference to the blue channel.
Color3f(const Eigen::ArrayBase< Derived > &p)
Construct a color vector from ArrayBase (needed to play nice with Eigen)
Color3f toSRGB() const
Convert from linear RGB to sRGB.
const float & g() const
Return a reference to the green channel (const version)
Color3f clamp() const
Clamp to the positive range.
Color3f & operator=(const Eigen::ArrayBase< Derived > &p)
Assign a color vector from ArrayBase (needed to play nice with Eigen)
Color3f(float r, float g, float b)
Initialize the color vector with specific per-channel values.
float & r()
Return a reference to the red channel.
Represents a linear RGB color and a weight.
Color4f(const Eigen::ArrayBase< Derived > &p)
Construct a color vector from ArrayBase (needed to play nice with Eigen)
Color4f()
Create an zero value.
Color4f(const Color3f &c)
Create from a 3-channel color.
std::string toString() const
Return a human-readable string summary.
Color4f & operator=(const Eigen::ArrayBase< Derived > &p)
Assign a color vector from ArrayBase (needed to play nice with Eigen)
Color4f(float r, float g, float b, float w)
Initialize the color vector with specific per-channel values.
Color3f divideByFilterWeight() const
Divide by the filter weight and convert into a Color3f value.