Standard RGBA color class with floating point elements and operations. More...
Classes | |
struct | mi::math::Spectrum_struct |
Generic storage class template for a Spectrum representation storing three floating point elements. More... | |
class | mi::math::Color |
Standard RGBA color class with floating point elements and operations. More... | |
struct | mi::math::Color_struct |
Generic storage class template for an RGBA color representation storing four floating points elements. More... | |
Typedefs | |
typedef Color_struct | mi::math::Color::Pod_type |
POD class corresponding to this color. More... | |
typedef Color_struct | mi::math::Color::storage_type |
Storage class used by this color. More... | |
typedef Float32 | mi::math::Color::value_type |
Element type. More... | |
typedef Size | mi::math::Color::size_type |
Size type, unsigned. More... | |
typedef Difference | mi::math::Color::difference_type |
Difference type, signed. More... | |
typedef Float32 * | mi::math::Color::pointer |
Mutable pointer to element. More... | |
typedef const Float32 * | mi::math::Color::const_pointer |
Const pointer to element. More... | |
typedef Float32 & | mi::math::Color::reference |
Mutable reference to element. More... | |
typedef const Float32 & | mi::math::Color::const_reference |
Const reference to element. More... | |
Enumerations | |
enum | mi::math::Clip_mode { mi::math::CLIP_RGB , mi::math::CLIP_ALPHA , mi::math::CLIP_RAW } |
Supported clipping modes. More... | |
Functions | |
static Size | mi::math::Color::size () |
Constant size of the color. More... | |
static Size | mi::math::Color::max_size () |
Constant maximum size of the color. More... | |
Float32 * | mi::math::Color::begin () |
Returns the pointer to the first color element. More... | |
const Float32 * | mi::math::Color::begin () const |
Returns the pointer to the first color element. More... | |
Float32 * | mi::math::Color::end () |
Returns the past-the-end pointer. More... | |
const Float32 * | mi::math::Color::end () const |
Returns the past-the-end pointer. More... | |
mi::math::Color::Color () | |
The default constructor leaves the color elements uninitialized. More... | |
mi::math::Color::Color (const Color &c)=default | |
Default copy constructor. More... | |
mi::math::Color::Color (const Color_struct &c) | |
Constructor from underlying storage type. More... | |
mi::math::Color::Color (const Float32 s) | |
Constructor initializes all vector elements to the value s . More... | |
mi::math::Color::Color (Float32 nr, Float32 ng, Float32 nb, Float32 na=1.0) | |
Constructor initializes (r,g,b,a) from (nr ,ng ,nb ,na ). More... | |
template<typename T> | |
mi::math::Color::Color (T array[4]) | |
Constructor initializes the color elements from a 4-dimensional array . More... | |
mi::math::Color::Color (const Vector< Float32, 4 > &v) | |
Constructor initializes (r,g,b,a) from (v.x , v.y , v.z , v.w ) of a compatible 4D vector v . More... | |
mi::math::Color::Color (const Spectrum_struct &s) | |
Conversion from Spectrum. More... | |
Color & | mi::math::Color::operator= (const Color &c) |
Assignment operator. More... | |
Color & | mi::math::Color::operator= (const Vector< Float32, 4 > &v) |
Assignment operator from compatible 4D vector, setting (r,g,b,a) to (v.x , v.y , v.z , v.w ). More... | |
const Float32 & | mi::math::Color::operator[] (Size i) const |
Accesses the i-th color element, 0 <= i < 4 . More... | |
Float32 & | mi::math::Color::operator[] (Size i) |
Accesses the i-th color element, 0 <= i < 4 . More... | |
Float32 | mi::math::Color::get (Size i) const |
Returns the i-th color element, 0 <= i < 4 . More... | |
void | mi::math::Color::set (Size i, Float32 value) |
Sets the i-th color element to value , 0 <= i < 4 . More... | |
bool | mi::math::Color::is_black () const |
Returns true if the color is black ignoring the alpha value. More... | |
Float32 | mi::math::Color::linear_intensity () const |
Returns the intensity of the RGB components, equally weighted. More... | |
Float32 | mi::math::Color::ntsc_intensity () const |
Returns the intensity of the RGB components, weighted according to the NTSC standard. More... | |
Float32 | mi::math::Color::cie_intensity () const |
Returns the intensity of the RGB components, weighted according to the CIE standard. More... | |
Color | mi::math::Color::clip (Clip_mode mode=CLIP_RGB, bool desaturate=false) const |
Returns this color clipped into the [0,1] range, according to the Clip_mode mode , and fades overbright colors to white if desaturate is true . More... | |
Color | mi::math::Color::desaturate (Float32 maxval=1.0f) const |
Returns this color clipped to the range [0,maxval ] using color desaturation. More... | |
bool | mi::math::operator== (const Color &lhs, const Color &rhs) |
Returns true if lhs is elementwise equal to rhs . More... | |
bool | mi::math::operator!= (const Color &lhs, const Color &rhs) |
Returns true if lhs is elementwise not equal to rhs . More... | |
bool | mi::math::operator< (const Color &lhs, const Color &rhs) |
Returns true if lhs is lexicographically less than rhs . More... | |
bool | mi::math::operator<= (const Color &lhs, const Color &rhs) |
Returns true if lhs is lexicographically less than or equal to rhs . More... | |
bool | mi::math::operator> (const Color &lhs, const Color &rhs) |
Returns true if lhs is lexicographically greater than rhs . More... | |
bool | mi::math::operator>= (const Color &lhs, const Color &rhs) |
Returns true if lhs is lexicographically greater than or equal to rhs . More... | |
Color & | mi::math::operator+= (Color &lhs, const Color &rhs) |
Adds rhs elementwise to lhs and returns the modified lhs . More... | |
Color & | mi::math::operator-= (Color &lhs, const Color &rhs) |
Subtracts rhs elementwise from lhs and returns the modified lhs . More... | |
Color & | mi::math::operator*= (Color &lhs, const Color &rhs) |
Multiplies rhs elementwise with lhs and returns the modified lhs . More... | |
Color & | mi::math::operator/= (Color &lhs, const Color &rhs) |
Divides lhs elementwise by rhs and returns the modified lhs . More... | |
Color | mi::math::operator+ (const Color &lhs, const Color &rhs) |
Adds lhs and rhs elementwise and returns the new result. More... | |
Color | mi::math::operator- (const Color &lhs, const Color &rhs) |
Subtracts rhs elementwise from lhs and returns the new result. More... | |
Color | mi::math::operator* (const Color &lhs, const Color &rhs) |
Multiplies rhs elementwise with lhs and returns the new result. More... | |
Color | mi::math::operator/ (const Color &lhs, const Color &rhs) |
Divides rhs elementwise by lhs and returns the new result. More... | |
Color | mi::math::operator- (const Color &c) |
Negates the color c elementwise and returns the new result. More... | |
Color & | mi::math::operator*= (Color &c, Float32 s) |
Multiplies the color c elementwise with the scalar s and returns the modified color c . More... | |
Color & | mi::math::operator/= (Color &c, Float32 s) |
Divides the color c elementwise by the scalar s and returns the modified color c . More... | |
Color | mi::math::operator* (const Color &c, Float32 s) |
Multiplies the color c elementwise with the scalar s and returns the new result. More... | |
Color | mi::math::operator* (Float32 s, const Color &c) |
Multiplies the color c elementwise with the scalar s and returns the new result. More... | |
Color | mi::math::operator/ (const Color &c, Float32 s) |
Divides the color c elementwise by the scalar s and returns the new result. More... | |
Color | mi::math::abs (const Color &c) |
Returns a color with the elementwise absolute values of the color c . More... | |
Color | mi::math::acos (const Color &c) |
Returns a color with the elementwise arc cosine of the color c . More... | |
bool | mi::math::all (const Color &c) |
Returns true if all elements of c are not equal to zero. More... | |
bool | mi::math::any (const Color &c) |
Returns true if any element of c is not equal to zero. More... | |
Color | mi::math::asin (const Color &c) |
Returns a color with the elementwise arc sine of the color c . More... | |
Color | mi::math::atan (const Color &c) |
Returns a color with the elementwise arc tangent of the color c . More... | |
Color | mi::math::atan2 (const Color &c, const Color &d) |
Returns a color with the elementwise arc tangent of the color c / d . More... | |
Color | mi::math::ceil (const Color &c) |
Returns a color with the elementwise smallest integral value that is not less than the element in color c . More... | |
Color | mi::math::clamp (const Color &c, const Color &low, const Color &high) |
Returns the color c elementwise clamped to the range [low , high ]. More... | |
Color | mi::math::clamp (const Color &c, const Color &low, Float32 high) |
Returns the color c elementwise clamped to the range [low , high ]. More... | |
Color | mi::math::clamp (const Color &c, Float32 low, const Color &high) |
Returns the color c elementwise clamped to the range [low , high ]. More... | |
Color | mi::math::clamp (const Color &c, Float32 low, Float32 high) |
Returns the color c elementwise clamped to the range [low , high ]. More... | |
Color | mi::math::cos (const Color &c) |
Returns a color with the elementwise cosine of the color c . More... | |
Color | mi::math::degrees (const Color &c) |
Converts elementwise radians in c to degrees. More... | |
Color | mi::math::elementwise_max (const Color &lhs, const Color &rhs) |
Returns elementwise max for each element in color lhs that is less than the corresponding element in color rhs . More... | |
Color | mi::math::elementwise_min (const Color &lhs, const Color &rhs) |
Returns elementwise min for each element in color lhs that is less than the corresponding element in color rhs . More... | |
Color | mi::math::exp (const Color &c) |
Returns a color with elementwise e to the power of the element in the color c . More... | |
Color | mi::math::exp2 (const Color &c) |
Returns a color with elementwise 2 to the power of the element in the color c . More... | |
Color | mi::math::floor (const Color &c) |
Returns a color with the elementwise largest integral value that is not greater than the element in color c . More... | |
Color | mi::math::fmod (const Color &a, const Color &b) |
Returns elementwise a modulo b , in other words, the remainder of a/b. More... | |
Color | mi::math::fmod (const Color &a, Float32 b) |
Returns elementwise a modulo b , in other words, the remainder of a/b. More... | |
Color | mi::math::frac (const Color &c) |
Returns a color with the elementwise positive fractional part of the color c . More... | |
Color | mi::math::gamma_correction (const Color &color, Float32 gamma_factor) |
Returns a gamma corrected color. More... | |
bool | mi::math::is_approx_equal (const Color &lhs, const Color &rhs, Float32 e) |
Compares the two given values elementwise for equality within the given epsilon. More... | |
Color | mi::math::lerp (const Color &c1, const Color &c2, const Color &t) |
Returns the elementwise linear interpolation between c1 and c2 , i.e., it returns (1-t) * c1 + t * c2 . More... | |
Color | mi::math::lerp (const Color &c1, const Color &c2, Float32 t) |
Returns the linear interpolation between c1 and c2 , i.e., it returns (1-t) * c1 + t * c2 . More... | |
Color | mi::math::log (const Color &c) |
Returns a color with elementwise natural logarithm of the color c . More... | |
Color | mi::math::log2 (const Color &c) |
Returns a color with elementwise base 2 logarithm of the color c . More... | |
Color | mi::math::log10 (const Color &c) |
Returns a color with elementwise base 10 logarithm of the color c . More... | |
Color | mi::math::modf (const Color &c, Color &i) |
Returns the elementwise fractional part of c and stores the elementwise integral part of c in i . More... | |
Color | mi::math::pow (const Color &a, const Color &b) |
Returns the color a elementwise to the power of b . More... | |
Color | mi::math::pow (const Color &a, Float32 b) |
Returns the color a elementwise to the power of b . More... | |
Color | mi::math::radians (const Color &c) |
Converts elementwise degrees in c to radians. More... | |
Color | mi::math::round (const Color &c) |
Returns a color with the elements of color c rounded to nearest integers. More... | |
Color | mi::math::rsqrt (const Color &c) |
Returns the reciprocal of the square root of each element of c . More... | |
Color | mi::math::saturate (const Color &c) |
Returns the color c clamped elementwise to the range [0,1]. More... | |
Color | mi::math::sign (const Color &c) |
Returns the elementwise sign of color c . More... | |
Color | mi::math::sin (const Color &c) |
Returns a color with the elementwise sine of the color c . More... | |
void | mi::math::sincos (const Color &a, Color &s, Color &c) |
Computes elementwise the sine s and cosine c of angles a simultaneously. More... | |
Color | mi::math::smoothstep (const Color &a, const Color &b, const Color &c) |
Returns 0 if c is less than a and 1 if c is greater than b in an elementwise fashion. More... | |
Color | mi::math::smoothstep (const Color &a, const Color &b, Float32 x) |
Returns 0 if c is less than a and 1 if c is greater than b in an elementwise fashion. More... | |
Color | mi::math::sqrt (const Color &c) |
Returns the square root of each element of c . More... | |
Color | mi::math::step (const Color &a, const Color &c) |
Returns elementwise 0 if c is less than a and 1 otherwise. More... | |
Color | mi::math::tan (const Color &c) |
Returns a color with the elementwise tangent of the color c . More... | |
bool | mi::math::isfinite (const Color &c) |
Indicates whether all components of the color are finite. More... | |
bool | mi::math::isinfinite (const Color &c) |
Indicates whether any component of the color is infinite. More... | |
bool | mi::math::isnan (const Color &c) |
Indicates whether any component of the color is "not a number". More... | |
MI_HOST_DEVICE_INLINE void | mi::math::to_rgbe (const Color &color, Uint32 &rgbe) |
Encodes a color into RGBE representation. More... | |
MI_HOST_DEVICE_INLINE void | mi::math::to_rgbe (const Color &color, Uint8 rgbe[4]) |
Encodes a color into RGBE representation. More... | |
MI_HOST_DEVICE_INLINE void | mi::math::from_rgbe (const Uint8 rgbe[4], Color &color) |
Decodes a color from RGBE representation. More... | |
MI_HOST_DEVICE_INLINE void | mi::math::from_rgbe (const Uint32 rgbe, Color &color) |
Decodes a color from RGBE representation. More... | |
Variables | |
Float32 | mi::math::Spectrum_struct::c [3] |
Three color bands. More... | |
static const Size | mi::math::Color::SIZE = 4 |
Constant size of the color. More... | |
Standard RGBA color class with floating point elements and operations.
#include <mi/math/color.h>
typedef const Float32* mi::math::Color::const_pointer |
Const pointer to element.
typedef const Float32& mi::math::Color::const_reference |
Const reference to element.
Difference type, signed.
POD class corresponding to this color.
typedef Float32* mi::math::Color::pointer |
Mutable pointer to element.
typedef Float32& mi::math::Color::reference |
Mutable reference to element.
typedef Size mi::math::Color::size_type |
Size type, unsigned.
Storage class used by this color.
typedef Float32 mi::math::Color::value_type |
Element type.
enum mi::math::Clip_mode |
Supported clipping modes.
Enumerator | |
---|---|
CLIP_RGB | First clip RGB to [0,1], then clip A to [max(R,G,B),1]. |
CLIP_ALPHA | First clip A to [0,1], then clip RGB to [0,A]. |
CLIP_RAW | Clip RGB and A to [0,1]. |
Returns a color with the elementwise absolute values of the color c
.
Returns a color with the elementwise arc cosine of the color c
.
|
inline |
Returns true
if all elements of c
are not equal to zero.
|
inline |
Returns true
if any element of c
is not equal to zero.
Returns a color with the elementwise arc sine of the color c
.
Returns a color with the elementwise arc tangent of the color c
.
Returns a color with the elementwise arc tangent of the color c
/ d
.
The signs of the elements of c
and d
are used to determine the quadrant of the results.
|
inline |
Returns the pointer to the first color element.
|
inline |
Returns the pointer to the first color element.
Returns a color with the elementwise smallest integral value that is not less than the element in color c
.
|
inline |
Returns the intensity of the RGB components, weighted according to the CIE standard.
Components are weighted to match the subjective color brightness perceived by the human eye; green appears brighter than blue.
Returns the color c
elementwise clamped to the range [low
, high
].
Returns the color c
elementwise clamped to the range [low
, high
].
Returns the color c
elementwise clamped to the range [low
, high
].
Returns the color c
elementwise clamped to the range [low
, high
].
Returns this color clipped into the [0,1] range, according to the Clip_mode
mode
, and fades overbright colors to white if desaturate
is true
.
|
inline |
The default constructor leaves the color elements uninitialized.
|
default |
Default copy constructor.
|
inline |
Constructor from underlying storage type.
|
inlineexplicit |
Constructor initializes all vector elements to the value s
.
|
inlineexplicit |
Conversion from Spectrum.
Constructor initializes (r,g,b,a) from (v.x
, v.y
, v.z
, v.w
) of a compatible 4D vector v
.
Constructor initializes (r,g,b,a) from (nr
,ng
,nb
,na
).
|
inlineexplicit |
Constructor initializes the color elements from a 4-dimensional array
.
The value type T
of the array
must be assignment compatible with the mi::Float32 type of the vector elements.
An example defining a red color:
Returns a color with the elementwise cosine of the color c
.
Returns this color clipped to the range [0,maxval
] using color desaturation.
This function tries to maintain the apparent brightness. It recognizes the brightness values of the different colors according to the NTSC standard. If possible, colors are adjusted by desaturating towards the brightness value.
For an explanation of color clipping using desaturation, see pp. 125-128 and pp. 251-252 of "Illumination and Color in Computer Generated Imagery" by Roy Hall.
Returns elementwise max for each element in color lhs
that is less than the corresponding element in color rhs
.
Returns elementwise min for each element in color lhs
that is less than the corresponding element in color rhs
.
|
inline |
|
inline |
Returns a color with elementwise e
to the power of the element in the color c
.
Returns a color with elementwise 2
to the power of the element in the color c
.
Returns a color with the elementwise largest integral value that is not greater than the element in color c
.
Returns elementwise a
modulo b
, in other words, the remainder of a/b.
The elementwise result has the same sign as a
.
Returns elementwise a
modulo b
, in other words, the remainder of a/b.
The elementwise result has the same sign as a
.
Returns a color with the elementwise positive fractional part of the color c
.
Decodes a color from RGBE representation.
Decodes a color from RGBE representation.
Returns a gamma corrected color.
Gamma factors are used to correct for non-linear input and output devices; for example, monitors typically have gamma factors between 1.7 and 2.2, meaning that one-half of the peak voltage does not give one half of the brightness. This is corrected for by raising the color components to the gamma exponent. Gamma factors greater than 1 make an image brighter; less than 1 make it darker. The inverse of gamma_correction(factor)
is gamma_correction
(1.0/factor).
color | color to be corrected |
gamma_factor | gamma factor, must be greater than zero. |
Compares the two given values elementwise for equality within the given epsilon.
|
inline |
Returns true
if the color is black ignoring the alpha value.
|
inline |
Indicates whether all components of the color are finite.
|
inline |
Indicates whether any component of the color is infinite.
|
inline |
Indicates whether any component of the color is "not a number".
Returns the elementwise linear interpolation between c1
and c2
, i.e., it returns (1-t) * c1 + t * c2
.
c1 | one color |
c2 | second color |
t | interpolation parameter in [0,1] |
Returns the linear interpolation between c1
and c2
, i.e., it returns (1-t) * c1 + t * c2
.
c1 | one color |
c2 | second color |
t | interpolation parameter in [0,1] |
|
inline |
Returns the intensity of the RGB components, equally weighted.
Returns a color with elementwise natural logarithm of the color c
.
Returns a color with elementwise base 10 logarithm of the color c
.
Returns a color with elementwise base 2 logarithm of the color c
.
|
inlinestatic |
Constant maximum size of the color.
Returns the elementwise fractional part of c
and stores the elementwise integral part of c
in i
.
Both parts have elementwise the same sign as c
.
|
inline |
Returns the intensity of the RGB components, weighted according to the NTSC standard.
Components are weighted to match the subjective color brightness perceived by the human eye; green appears brighter than blue.
|
inline |
Returns true
if lhs
is elementwise not equal to rhs
.
Multiplies the color c
elementwise with the scalar s
and returns the new result.
Multiplies rhs
elementwise with lhs
and returns the new result.
Multiplies the color c
elementwise with the scalar s
and returns the new result.
Multiplies the color c
elementwise with the scalar s
and returns the modified color c
.
Multiplies rhs
elementwise with lhs
and returns the modified lhs
.
Adds lhs
and rhs
elementwise and returns the new result.
Adds rhs
elementwise to lhs
and returns the modified lhs
.
Negates the color c
elementwise and returns the new result.
Subtracts rhs
elementwise from lhs
and returns the new result.
Subtracts rhs
elementwise from lhs
and returns the modified lhs
.
Divides the color c
elementwise by the scalar s
and returns the new result.
Divides rhs
elementwise by lhs
and returns the new result.
Divides the color c
elementwise by the scalar s
and returns the modified color c
.
Divides lhs
elementwise by rhs
and returns the modified lhs
.
Returns true
if lhs
is lexicographically less than rhs
.
Returns true
if lhs
is lexicographically less than or equal to rhs
.
Assignment operator from compatible 4D vector, setting (r,g,b,a) to (v.x
, v.y
, v.z
, v.w
).
Returns true
if lhs
is elementwise equal to rhs
.
Returns true
if lhs
is lexicographically greater than rhs
.
Returns true
if lhs
is lexicographically greater than or equal to rhs
.
Accesses the i-th
color element, 0 <= i < 4
.
Returns the color a
elementwise to the power of b
.
Returns the color a
elementwise to the power of b
.
Returns a color with the elements of color c
rounded to nearest integers.
Returns the reciprocal of the square root of each element of c
.
Returns the color c
clamped elementwise to the range [0,1].
Sets the i-th
color element to value
, 0 <= i < 4
.
Returns a color with the elementwise sine of the color c
.
Computes elementwise the sine s
and cosine c
of angles a
simultaneously.
The angles a
are specified in radians.
|
inlinestatic |
Constant size of the color.
Returns 0 if c
is less than a
and 1 if c
is greater than b
in an elementwise fashion.
A smooth curve is applied in-between so that the return values vary continuously from 0 to 1 as elements in c
vary from a
to b
.
Returns 0 if c
is less than a
and 1 if c
is greater than b
in an elementwise fashion.
A smooth curve is applied in-between so that the return values vary continuously from 0 to 1 as x
varies from a
to b
.
Returns elementwise 0 if c
is less than a
and 1 otherwise.
Returns a color with the elementwise tangent of the color c
.
Encodes a color into RGBE representation.
Encodes a color into RGBE representation.
Float32 mi::math::Spectrum_struct::c[3] |
Three color bands.
|
static |
Constant size of the color.