neuray API Programmer's Manual

Color Class

[Math API]

Description

Standard RGBA color class with floating point elements and operations.

Include File:

#include <mi/math/color.h>

Classes

class 
Standard RGBA color class with floating point elements and operations. More...
struct 
Generic storage class template for an RGBA color representation storing four floating points elements. More...
struct 
Generic storage class template for a Spectrum representation storing three floating point elements. More...

Enumerations

enum mi::math::Clip_mode{ CLIP_RGB, CLIP_ALPHA, CLIP_RAW}
Supported clipping modes. More...

Functions

Color mi::math::abs( const Color& c)
Returns a color with the elementwise absolute values of the color c.
Color mi::math::acos( const Color& c)
Returns a color with the elementwise arc cosine of the color c.
bool  mi::math::all( const Color& c)
Returns true if all elements of c are not equal to zero.
bool  mi::math::any( const Color& c)
Returns true if any element of c is not equal to zero.
Color mi::math::asin( const Color& c)
Returns a color with the elementwise arc sine of the color c.
Color mi::math::atan( const Color& c)
Returns a color with the elementwise arc tangent of the color c.
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.
Color mi::math::clamp( const Color& c, const Color& low, const Color& high)
Returns the color c elementwise clamped to the range [low, high].
Color mi::math::clamp( const Color& c, const Color& low, Float32 high)
Returns the color c elementwise clamped to the range [low, high].
Color mi::math::clamp( const Color& c, Float32 low, const Color& high)
Returns the color c elementwise clamped to the range [low, high].
Color mi::math::clamp( const Color& c, Float32 low, Float32 high)
Returns the color c elementwise clamped to the range [low, high].
Color mi::math::cos( const Color& c)
Returns a color with the elementwise cosine of the color c.
Color mi::math::degrees( const Color& c)
Converts elementwise radians in c to degrees.
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.
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.
Color mi::math::exp( const Color& c)
Returns a color with elementwise e to the power of the element in the color c.
Color mi::math::exp2( const Color& c)
Returns a color with elementwise 2 to the power of the element in the color c.
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.
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.
void mi::math::from_rgbe( const Uint8 rgbe[4], Color& color)
Decodes a color from RGBE representation. More...
void mi::math::from_rgbe( const Uint32 rgbe, Color& color)
Decodes a color from RGBE representation. 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.
bool  mi::math::isfinite( const Color& c)
Indicates whether all components of the color are finite.
bool  mi::math::isinfinite( const Color& c)
Indicates whether any component of the color is infinite.
bool  mi::math::isnan( const Color& c)
Indicates whether any component of the color is "not a number".
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.
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.
Color mi::math::log( const Color& c)
Returns a color with elementwise natural logarithm of the color c.
Color mi::math::log10( const Color& c)
Returns a color with elementwise base 10 logarithm of the color c.
Color mi::math::log2( const Color& c)
Returns a color with elementwise base 2 logarithm of the color c.
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...
bool  mi::math::operator!=( const Color& lhs, const Color& rhs)
Returns true if lhs is elementwise not equal to rhs.
Color mi::math::operator*( const Color& lhs, const Color& rhs)
Multiplies rhs elementwise with lhs and returns the new result.
Color mi::math::operator*( const Color& c, Float32 s)
Multiplies the color c elementwise with the scalar s and returns the new result.
Color mi::math::operator*( Float32 s, const Color& c)
Multiplies the color c elementwise with the scalar s and returns the new result.
Color& mi::math::operator*=( Color& lhs, const Color& rhs)
Multiplies rhs elementwise with lhs and returns the modified lhs.
Color& mi::math::operator*=( Color& c, Float32 s)
Multiplies the color c elementwise with the scalar s and returns the modified color c.
Color mi::math::operator+( const Color& lhs, const Color& rhs)
Adds lhs and rhs elementwise and returns the new result.
Color& mi::math::operator+=( Color& lhs, const Color& rhs)
Adds rhs elementwise to lhs and returns the modified lhs.
Color mi::math::operator-( const Color& lhs, const Color& rhs)
Subtracts rhs elementwise from lhs and returns the new result.
Color mi::math::operator-( const Color& c)
Negates the color c elementwise and returns the new result.
Color& mi::math::operator-=( Color& lhs, const Color& rhs)
Subtracts rhs elementwise from lhs and returns the modified lhs.
Color mi::math::operator/( const Color& lhs, const Color& rhs)
Divides rhs elementwise by lhs and returns the new result.
Color mi::math::operator/( const Color& c, Float32 s)
Divides the color c elementwise by the scalar s and returns the new result.
Color& mi::math::operator/=( Color& lhs, const Color& rhs)
Divides lhs elementwise by rhs and returns the modified lhs.
Color& mi::math::operator/=( Color& c, Float32 s)
Divides the color c elementwise by the scalar s and returns the modified color c.
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 elementwise equal to rhs.
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::pow( const Color& a, const Color& b)
Returns the color a elementwise to the power of b.
Color mi::math::pow( const Color& a, Float32 b)
Returns the color a elementwise to the power of b.
Color mi::math::radians( const Color& c)
Converts elementwise degrees in c to radians.
Color mi::math::round( const Color& c)
Returns a color with the elements of color c rounded to nearest integers.
Color mi::math::rsqrt( const Color& c)
Returns the reciprocal of the square root of each element of c.
Color mi::math::saturate( const Color& c)
Returns the color c clamped elementwise to the range [0,1].
Color mi::math::sign( const Color& c)
Returns the elementwise sign of color c.
Color mi::math::sin( const Color& c)
Returns a color with the elementwise sine of the color c.
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.
Color mi::math::step( const Color& a, const Color& c)
Returns elementwise 0 if c is less than a and 1 otherwise.
Color mi::math::tan( const Color& c)
Returns a color with the elementwise tangent of the color c.
void mi::math::to_rgbe( const Color& color, Uint32& rgbe)
Encodes a color into RGBE representation. More...
void mi::math::to_rgbe( const Color& color, Uint8 rgbe[4])
Encodes a color into RGBE representation. More...

Enums

enum mi::math::Clip_mode

Supported clipping modes.

See also:

mi::Color::clip() function.

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].

Functions

Color mi::math::abs( const Color& c) [inline]

Returns a color with the elementwise absolute values of the color c.

Color mi::math::acos( const Color& c) [inline]

Returns a color with the elementwise arc cosine of the color c.

bool mi::math::all( const Color& c) [inline]

Returns true if all elements of c are not equal to zero.

bool mi::math::any( const Color& c) [inline]

Returns true if any element of c is not equal to zero.

Color mi::math::asin( const Color& c) [inline]

Returns a color with the elementwise arc sine of the color c.

Color mi::math::atan( const Color& c) [inline]

Returns a color with the elementwise arc tangent of the color c.

Color mi::math::atan2( const Color& c, const Color& d) [inline]

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.

Color mi::math::ceil( const Color& c) [inline]

Returns a color with the elementwise smallest integral value that is not less than the element in color c.

Color mi::math::clamp( const Color& c, const Color& low, const Color& high) [inline]

Returns the color c elementwise clamped to the range [low, high].

Color mi::math::clamp( const Color& c, const Color& low, Float32 high) [inline]

Returns the color c elementwise clamped to the range [low, high].

Color mi::math::clamp( const Color& c, Float32 low, const Color& high) [inline]

Returns the color c elementwise clamped to the range [low, high].

Color mi::math::clamp( const Color& c, Float32 low, Float32 high) [inline]

Returns the color c elementwise clamped to the range [low, high].

Color mi::math::cos( const Color& c) [inline]

Returns a color with the elementwise cosine of the color c.

Color mi::math::degrees( const Color& c) [inline]

Converts elementwise radians in c to degrees.

Color mi::math::elementwise_max( const Color& lhs, const Color& rhs) [inline]

Returns elementwise max for each element in color lhs that is less than the corresponding element in color rhs.

Color mi::math::elementwise_min( const Color& lhs, const Color& rhs) [inline]

Returns elementwise min for each element in color lhs that is less than the corresponding element in color rhs.

Color mi::math::exp( const Color& c) [inline]

Returns a color with elementwise e to the power of the element in the color c.

Color mi::math::exp2( const Color& c) [inline]

Returns a color with elementwise 2 to the power of the element in the color c.

Color mi::math::floor( const Color& c) [inline]

Returns a color with the elementwise largest integral value that is not greater than the element in color c.

Color mi::math::fmod( const Color& a, const Color& b) [inline]

Returns elementwise a modulo b, in other words, the remainder of a/b. The elementwise result has the same sign as a.

Color mi::math::fmod( const Color& a, Float32 b) [inline]

Returns elementwise a modulo b, in other words, the remainder of a/b. The elementwise result has the same sign as a.

Color mi::math::frac( const Color& c) [inline]

Returns a color with the elementwise positive fractional part of the color c.

void mi::math::from_rgbe( const Uint8 rgbe[4], Color& color) [inline]

Decodes a color from RGBE representation.

Note:

The alpha value is set to 1.0.

void mi::math::from_rgbe( const Uint32 rgbe, Color& color) [inline]

Decodes a color from RGBE representation.

Note:

The alpha value is set to 1.0.

Color mi::math::gamma_correction( const Color& color, Float32 gamma_factor) [inline]

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).

Parameters

color
color to be corrected
gamma_factor
gamma factor, must be greater than zero.
bool mi::math::is_approx_equal( const Color& lhs, const Color& rhs, Float32 e) [inline]

Compares the two given values elementwise for equality within the given epsilon.

bool mi::math::isfinite( const Color& c) [inline]

Indicates whether all components of the color are finite.

bool mi::math::isinfinite( const Color& c) [inline]

Indicates whether any component of the color is infinite.

bool mi::math::isnan( const Color& c) [inline]

Indicates whether any component of the color is "not a number".

Color mi::math::lerp( const Color& c1, const Color& c2, const Color& t) [inline]

Returns the elementwise linear interpolation between c1 and c2, i.e., it returns (1-t) * c1 + t * c2.

Parameters

c1
one color
c2
second color
t
interpolation parameter in [0,1]
Color mi::math::lerp( const Color& c1, const Color& c2, Float32 t) [inline]

Returns the linear interpolation between c1 and c2, i.e., it returns (1-t) * c1 + t * c2.

Parameters

c1
one color
c2
second color
t
interpolation parameter in [0,1]
Color mi::math::log( const Color& c) [inline]

Returns a color with elementwise natural logarithm of the color c.

Color mi::math::log10( const Color& c) [inline]

Returns a color with elementwise base 10 logarithm of the color c.

Color mi::math::log2( const Color& c) [inline]

Returns a color with elementwise base 2 logarithm of the color c.

Color mi::math::modf( const Color& c, Color& i) [inline]

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.

bool mi::math::operator!=( const Color& lhs, const Color& rhs) [inline]

Returns true if lhs is elementwise not equal to rhs.

Color mi::math::operator*( const Color& lhs, const Color& rhs) [inline]

Multiplies rhs elementwise with lhs and returns the new result.

Color mi::math::operator*( const Color& c, Float32 s) [inline]

Multiplies the color c elementwise with the scalar s and returns the new result.

Color mi::math::operator*( Float32 s, const Color& c) [inline]

Multiplies the color c elementwise with the scalar s and returns the new result.

Color& mi::math::operator*=( Color& lhs, const Color& rhs) [inline]

Multiplies rhs elementwise with lhs and returns the modified lhs.

Color& mi::math::operator*=( Color& c, Float32 s) [inline]

Multiplies the color c elementwise with the scalar s and returns the modified color c.

Color mi::math::operator+( const Color& lhs, const Color& rhs) [inline]

Adds lhs and rhs elementwise and returns the new result.

Color& mi::math::operator+=( Color& lhs, const Color& rhs) [inline]

Adds rhs elementwise to lhs and returns the modified lhs.

Color mi::math::operator-( const Color& lhs, const Color& rhs) [inline]

Subtracts rhs elementwise from lhs and returns the new result.

Color mi::math::operator-( const Color& c) [inline]

Negates the color c elementwise and returns the new result.

Color& mi::math::operator-=( Color& lhs, const Color& rhs) [inline]

Subtracts rhs elementwise from lhs and returns the modified lhs.

Color mi::math::operator/( const Color& lhs, const Color& rhs) [inline]

Divides rhs elementwise by lhs and returns the new result.

Color mi::math::operator/( const Color& c, Float32 s) [inline]

Divides the color c elementwise by the scalar s and returns the new result.

Color& mi::math::operator/=( Color& lhs, const Color& rhs) [inline]

Divides lhs elementwise by rhs and returns the modified lhs.

Color& mi::math::operator/=( Color& c, Float32 s) [inline]

Divides the color c elementwise by the scalar s and returns the modified color c.

bool mi::math::operator<( const Color& lhs, const Color& rhs) [inline]

Returns true if lhs is lexicographically less than rhs.

See also:

mi_def_lexicographic_order

bool mi::math::operator<=( const Color& lhs, const Color& rhs) [inline]

Returns true if lhs is lexicographically less than or equal to rhs.

See also:

mi_def_lexicographic_order

bool mi::math::operator==( const Color& lhs, const Color& rhs) [inline]

Returns true if lhs is elementwise equal to rhs.

bool mi::math::operator>( const Color& lhs, const Color& rhs) [inline]

Returns true if lhs is lexicographically greater than rhs.

See also:

mi_def_lexicographic_order

bool mi::math::operator>=( const Color& lhs, const Color& rhs) [inline]

Returns true if lhs is lexicographically greater than or equal to rhs.

See also:

mi_def_lexicographic_order

Color mi::math::pow( const Color& a, const Color& b) [inline]

Returns the color a elementwise to the power of b.

Color mi::math::pow( const Color& a, Float32 b) [inline]

Returns the color a elementwise to the power of b.

Color mi::math::radians( const Color& c) [inline]

Converts elementwise degrees in c to radians.

Color mi::math::round( const Color& c) [inline]

Returns a color with the elements of color c rounded to nearest integers.

Color mi::math::rsqrt( const Color& c) [inline]

Returns the reciprocal of the square root of each element of c.

Color mi::math::saturate( const Color& c) [inline]

Returns the color c clamped elementwise to the range [0,1].

Color mi::math::sign( const Color& c) [inline]

Returns the elementwise sign of color c.

Color mi::math::sin( const Color& c) [inline]

Returns a color with the elementwise sine of the color c.

void mi::math::sincos( const Color& a, Color& s, Color& c) [inline]

Computes elementwise the sine s and cosine c of angles a simultaneously. The angles a are specified in radians.

Color mi::math::smoothstep( const Color& a, const Color& b, const Color& c) [inline]

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.

Color mi::math::smoothstep( const Color& a, const Color& b, Float32 x) [inline]

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.

Color mi::math::sqrt( const Color& c) [inline]

Returns the square root of each element of c.

Color mi::math::step( const Color& a, const Color& c) [inline]

Returns elementwise 0 if c is less than a and 1 otherwise.

Color mi::math::tan( const Color& c) [inline]

Returns a color with the elementwise tangent of the color c.

void mi::math::to_rgbe( const Color& color, Uint32& rgbe) [inline]

Encodes a color into RGBE representation.

Note:

The alpha value is not part of the RGBE representation.

void mi::math::to_rgbe( const Color& color, Uint8 rgbe[4]) [inline]

Encodes a color into RGBE representation.

Note:

The alpha value is not part of the RGBE representation.