RenderMan API  23.0
RixColorUtils.h File Reference
#include "RixShadingUtils.h"

Go to the source code of this file.

Macros

#define F_LOGDOTFIVE   (-0.30102999566f)
 
#define F_INVLOGDOTFIVE   (-3.32192809489f)
 
#define IFLOOR(x)   (((x) < 0.0f && (x) != (int)(x)) ? (int)x - 1 : (int)x)
 

Enumerations

enum  RixColorSpace {
  k_sRGB = 0, k_Rec709, k_Rec2020, k_DCI_P3,
  k_Alexa_wide, k_ACEScg, k_CinemaGamut, k_NTSC,
  k_numColorSpaces
}
 

Functions

PRMAN_INLINE void RixHsvToRgb (RtColorRGB const &hsv, RtColorRGB &rgb)
 
PRMAN_INLINE void RixRgbToHsv (RtColorRGB const &rgb, RtColorRGB &hsv)
 
PRMAN_INLINE float rixValue (float n1, float n2, float hue)
 
PRMAN_INLINE void RixHslToRgb (RtColorRGB const &hsl, RtColorRGB &rgb)
 
PRMAN_INLINE void RixRgbToHsl (RtColorRGB const &rgb, RtColorRGB &hsl)
 
PRMAN_INLINE void RixXyzToRgb (RtColorRGB const &xyz, RtColorRGB &rgb, RixColorSpace cs=k_sRGB)
 
PRMAN_INLINE void RixRgbToXyz (RtColorRGB const &rgb, RtColorRGB &xyz, RixColorSpace cs=k_sRGB)
 
PRMAN_INLINE RtFloat RixInputRange (const RtFloat &f, const RtFloat &min, const RtFloat &max)
 Remap [min, max] to [0.0 to 1.0]. More...
 
PRMAN_INLINE RtColorRGB RixInputRange (const RtColorRGB &rgb, const RtFloat &min, const RtFloat &max)
 Remap [min, max] to [0.0 to 1.0]. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixInputRange (const RtColorRGB &rgb, const T &min, const T &max)
 Remap [min, max] to [0.0 to 1.0]. More...
 
PRMAN_INLINE RtFloat RixOutputRange (const RtFloat &f, const RtFloat &min, const RtFloat &max)
 Remap a float from [0.0, 1.0] to [min, max]. More...
 
PRMAN_INLINE RtColorRGB RixOutputRange (const RtColorRGB &rgb, const RtFloat &min, const RtFloat &max)
 Remap a color from [0.0, 1.0] to [min, max]. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixOutputRange (const RtColorRGB &rgb, const T &min, const T &max)
 Remap a color from [0.0, 1.0] to [min, max]. More...
 
PRMAN_INLINE RtFloat RixExposure (RtFloat const &f, RtFloat const &e)
 Float exposure function. More...
 
PRMAN_INLINE RtColorRGB RixExposure (const RtColorRGB &rgb, const RtFloat &e)
 Color exposure function. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixExposure (const RtColorRGB &rgb, const T &e)
 Color exposure function. More...
 
PRMAN_INLINE RtFloat RixGamma (const RtFloat &f, const RtFloat &g)
 Float gamma correction. More...
 
PRMAN_INLINE RtColorRGB RixGamma (const RtColorRGB &rgb, const RtFloat &g)
 Color gamma correction. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixGamma (const RtColorRGB &rgb, const T &g)
 Color gamma correction. More...
 
PRMAN_INLINE RtFloat RixContrast (RtFloat f, RtFloat contrast, RtFloat pivot)
 Contrast float function. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixContrast (const RtColorRGB &rgb, const T &contrast, const T &pivot)
 Color contrast function. More...
 
PRMAN_INLINE RtColorRGB RixHsvCorrect (const RtColorRGB &rgb, const RtFloat &hue, const RtFloat &sat, const RtFloat &val)
 HSV color correction. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixHsvCorrect (const RtColorRGB &rgb, const T &hsv)
 HSV color correction. Hue, saturation and value are packed in a RtFloat3 container. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixHslCorrect (const RtColorRGB &rgb, const T &hsl)
 HSL color correction. More...
 
template<typename T >
PRMAN_INLINE RtColorRGB RixColorClamp (const RtColorRGB &rgb, const T &min, const T &max)
 Clamp color : this an extensions of RixClamp. More...
 
PRMAN_INLINE RtColorRGB RixSaturation (const RtColorRGB &rgb, const float saturation)
 Return the saturation-adjusted color. More...
 
PRMAN_INLINE void RixSaturation (RtColorRGB &rgb, const float saturation)
 Adjust the color saturation of the passed color. More...
 

Macro Definition Documentation

◆ F_INVLOGDOTFIVE

#define F_INVLOGDOTFIVE   (-3.32192809489f)

Definition at line 44 of file RixColorUtils.h.

◆ F_LOGDOTFIVE

#define F_LOGDOTFIVE   (-0.30102999566f)

Definition at line 43 of file RixColorUtils.h.

◆ IFLOOR

#define IFLOOR (   x)    (((x) < 0.0f && (x) != (int)(x)) ? (int)x - 1 : (int)x)

Definition at line 159 of file RixColorUtils.h.

Enumeration Type Documentation

◆ RixColorSpace

Enumerator
k_sRGB 
k_Rec709 
k_Rec2020 
k_DCI_P3 
k_Alexa_wide 
k_ACEScg 
k_CinemaGamut 
k_NTSC 
k_numColorSpaces 

Definition at line 46 of file RixColorUtils.h.

Function Documentation

◆ RixColorClamp()

template<typename T >
PRMAN_INLINE RtColorRGB RixColorClamp ( const RtColorRGB rgb,
const T &  min,
const T &  max 
)

Clamp color : this an extensions of RixClamp.

Parameters
[in]rgbThe rgb input
[in]minThe minimum color
[in]maxThe maximum color
Template Parameters
TAny RtFloat3 container
Returns
The clamped color.

Definition at line 813 of file RixColorUtils.h.

◆ RixContrast() [1/2]

PRMAN_INLINE RtFloat RixContrast ( RtFloat  f,
RtFloat  contrast,
RtFloat  pivot 
)

Contrast float function.

Parameters
[in]finput float value
[in]contrastThe amount of contrast, from -1 to 1. 0 is neutral.
[in]pivotThe pivot value of the contrast curve.
Returns
float value

Definition at line 683 of file RixColorUtils.h.

◆ RixContrast() [2/2]

template<typename T >
PRMAN_INLINE RtColorRGB RixContrast ( const RtColorRGB rgb,
const T &  contrast,
const T &  pivot 
)

Color contrast function.

Parameters
[in]rgbThe rgb input
[in]contrastThe contrast value between -1 and +1
[in]pivotThe pivot of the contrast curve.
Template Parameters
TAny RtFloat3 container.
Returns
Adjusted color value.

Definition at line 722 of file RixColorUtils.h.

◆ RixExposure() [1/3]

PRMAN_INLINE RtFloat RixExposure ( RtFloat const &  f,
RtFloat const &  e 
)

Float exposure function.

Parameters
ffloat input value
eexposure value.
Returns
float result

Definition at line 564 of file RixColorUtils.h.

◆ RixExposure() [2/3]

PRMAN_INLINE RtColorRGB RixExposure ( const RtColorRGB rgb,
const RtFloat e 
)

Color exposure function.

Parameters
[in]rgbThe rgb input
[in]eThe float exposure value
Returns
The modified color

Definition at line 580 of file RixColorUtils.h.

◆ RixExposure() [3/3]

template<typename T >
PRMAN_INLINE RtColorRGB RixExposure ( const RtColorRGB rgb,
const T &  e 
)

Color exposure function.

Parameters
[in]rgbThe rgb input
[in]eThe T exposure value
Template Parameters
TAny RtFloat3 container
Returns
The modified color

Definition at line 605 of file RixColorUtils.h.

◆ RixGamma() [1/3]

PRMAN_INLINE RtFloat RixGamma ( const RtFloat f,
const RtFloat g 
)

Float gamma correction.

Parameters
[in]fThe float input value
[in]gThe float gamma value
Returns
The modified float value.

Definition at line 623 of file RixColorUtils.h.

◆ RixGamma() [2/3]

PRMAN_INLINE RtColorRGB RixGamma ( const RtColorRGB rgb,
const RtFloat g 
)

Color gamma correction.

Parameters
[in]rgbThe rgb input
[in]gThe float gamma value
Returns
The modified color

Definition at line 639 of file RixColorUtils.h.

◆ RixGamma() [3/3]

template<typename T >
PRMAN_INLINE RtColorRGB RixGamma ( const RtColorRGB rgb,
const T &  g 
)

Color gamma correction.

Parameters
[in]rgbThe rgb input
[in]gThe T gamma value
Template Parameters
TAny RtFloat3 container
Returns
The modified color

Definition at line 664 of file RixColorUtils.h.

◆ RixHslCorrect()

template<typename T >
PRMAN_INLINE RtColorRGB RixHslCorrect ( const RtColorRGB rgb,
const T &  hsl 
)

HSL color correction.

Parameters
[in]rgbThe rgb input
[in]hslThe hsl values.
Template Parameters
TAny RtFloat3 container
Returns
Adjusted color

Definition at line 789 of file RixColorUtils.h.

◆ RixHslToRgb()

PRMAN_INLINE void RixHslToRgb ( RtColorRGB const &  hsl,
RtColorRGB rgb 
)

Definition at line 335 of file RixColorUtils.h.

◆ RixHsvCorrect() [1/2]

PRMAN_INLINE RtColorRGB RixHsvCorrect ( const RtColorRGB rgb,
const RtFloat hue,
const RtFloat sat,
const RtFloat val 
)

HSV color correction.

Parameters
[in]rgbThe rgb input
[in]hueThe hue offset
[in]satThe saturation multiplier
[in]valThe value multiplier
Returns
Adjusted color

Definition at line 741 of file RixColorUtils.h.

◆ RixHsvCorrect() [2/2]

template<typename T >
PRMAN_INLINE RtColorRGB RixHsvCorrect ( const RtColorRGB rgb,
const T &  hsv 
)

HSV color correction. Hue, saturation and value are packed in a RtFloat3 container.

Parameters
[in]rgbThe rgb input
[in]hsvThe hsv values in a RtFloat3 container.
Template Parameters
TCan be any RtFloat3 container.
Returns
Adjusted color.

Definition at line 766 of file RixColorUtils.h.

◆ RixHsvToRgb()

PRMAN_INLINE void RixHsvToRgb ( RtColorRGB const &  hsv,
RtColorRGB rgb 
)

Definition at line 162 of file RixColorUtils.h.

◆ RixInputRange() [1/3]

PRMAN_INLINE RtFloat RixInputRange ( const RtFloat f,
const RtFloat min,
const RtFloat max 
)

Remap [min, max] to [0.0 to 1.0].

Parameters
[in]fThe input float value
[in]minThe float value that will be remapped to 0.0
[in]maxThe float value that will be remapped to 1.0
Returns
The remapped float value.

Definition at line 451 of file RixColorUtils.h.

◆ RixInputRange() [2/3]

PRMAN_INLINE RtColorRGB RixInputRange ( const RtColorRGB rgb,
const RtFloat min,
const RtFloat max 
)

Remap [min, max] to [0.0 to 1.0].

Parameters
[in]rgbThe input color value
[in]minThe float value that will be remapped to 0.0
[in]maxThe float value that will be remapped to 1.0
Returns
The remapped color.

Definition at line 470 of file RixColorUtils.h.

◆ RixInputRange() [3/3]

template<typename T >
PRMAN_INLINE RtColorRGB RixInputRange ( const RtColorRGB rgb,
const T &  min,
const T &  max 
)

Remap [min, max] to [0.0 to 1.0].

Parameters
[in]rgbThe input color value
[in]minThe T value that will be remapped to 0.0
[in]maxThe T value that will be remapped to 1.0
Template Parameters
TAny RtFloat3 container.
Returns
The remapped color.

Definition at line 491 of file RixColorUtils.h.

◆ RixOutputRange() [1/3]

PRMAN_INLINE RtFloat RixOutputRange ( const RtFloat f,
const RtFloat min,
const RtFloat max 
)

Remap a float from [0.0, 1.0] to [min, max].

Parameters
[in]fThe input float value
[in]minThe float value to which 0.0 will be remapped.
[in]maxThe float value to which 1.0 will be remapped.
Returns
The remapped float value

Definition at line 509 of file RixColorUtils.h.

◆ RixOutputRange() [2/3]

PRMAN_INLINE RtColorRGB RixOutputRange ( const RtColorRGB rgb,
const RtFloat min,
const RtFloat max 
)

Remap a color from [0.0, 1.0] to [min, max].

Parameters
[in]rgbThe input rgb
[in]minThe float value to which 0.0 will be remapped.
[in]maxThe float value to which 1.0 will be remapped.
Returns
The remapped color

Definition at line 526 of file RixColorUtils.h.

◆ RixOutputRange() [3/3]

template<typename T >
PRMAN_INLINE RtColorRGB RixOutputRange ( const RtColorRGB rgb,
const T &  min,
const T &  max 
)

Remap a color from [0.0, 1.0] to [min, max].

Parameters
[in]rgbThe input rgb
[in]minThe T value to which 0.0 will be remapped.
[in]maxThe T value to which 1.0 will be remapped.
Template Parameters
TAny RtFloat3 container.
Returns
The remapped color.

Definition at line 547 of file RixColorUtils.h.

◆ RixRgbToHsl()

PRMAN_INLINE void RixRgbToHsl ( RtColorRGB const &  rgb,
RtColorRGB hsl 
)

Definition at line 363 of file RixColorUtils.h.

◆ RixRgbToHsv()

PRMAN_INLINE void RixRgbToHsv ( RtColorRGB const &  rgb,
RtColorRGB hsv 
)

Definition at line 214 of file RixColorUtils.h.

◆ RixRgbToXyz()

PRMAN_INLINE void RixRgbToXyz ( RtColorRGB const &  rgb,
RtColorRGB xyz,
RixColorSpace  cs = k_sRGB 
)

Definition at line 431 of file RixColorUtils.h.

◆ RixSaturation() [1/2]

PRMAN_INLINE RtColorRGB RixSaturation ( const RtColorRGB rgb,
const float  saturation 
)

Return the saturation-adjusted color.

Note
This is faster than HSV or HSL if you only need saturation.
Parameters
[in]rgbThe rgb input
[in]saturation0.0 is monochrome (fully desaturated), 1.0 is the original color, values > 1.0 increase color saturation.
Returns
The saturation-adjusted color.

Definition at line 833 of file RixColorUtils.h.

◆ RixSaturation() [2/2]

PRMAN_INLINE void RixSaturation ( RtColorRGB rgb,
const float  saturation 
)

Adjust the color saturation of the passed color.

Note
This is faster than HSV or HSL if you only need saturation.
Parameters
[in]rgbThe rgb input
[in]saturation0.0 is monochrome (fully desaturated), 1.0 is the original color, values > 1.0 increase color saturation.

Definition at line 856 of file RixColorUtils.h.

◆ rixValue()

PRMAN_INLINE float rixValue ( float  n1,
float  n2,
float  hue 
)

Definition at line 321 of file RixColorUtils.h.

◆ RixXyzToRgb()

PRMAN_INLINE void RixXyzToRgb ( RtColorRGB const &  xyz,
RtColorRGB rgb,
RixColorSpace  cs = k_sRGB 
)

Definition at line 420 of file RixColorUtils.h.