13 void hsv_to_rgb(
float h,
float s,
float v,
float *r_r,
float *r_g,
float *r_b)
17 nr =
fabsf(h * 6.0f - 3.0f) - 1.0f;
18 ng = 2.0f -
fabsf(h * 6.0f - 2.0f);
19 nb = 2.0f -
fabsf(h * 6.0f - 4.0f);
21 CLAMP(nr, 0.0f, 1.0f);
22 CLAMP(nb, 0.0f, 1.0f);
23 CLAMP(ng, 0.0f, 1.0f);
25 *r_r = ((nr - 1.0f) * s + 1.0f) *
v;
26 *r_g = ((ng - 1.0f) * s + 1.0f) *
v;
27 *r_b = ((nb - 1.0f) * s + 1.0f) *
v;
30 void hsl_to_rgb(
float h,
float s,
float l,
float *r_r,
float *r_g,
float *r_b)
32 float nr, ng, nb, chroma;
34 nr =
fabsf(h * 6.0f - 3.0f) - 1.0f;
35 ng = 2.0f -
fabsf(h * 6.0f - 2.0f);
36 nb = 2.0f -
fabsf(h * 6.0f - 4.0f);
38 CLAMP(nr, 0.0f, 1.0f);
39 CLAMP(nb, 0.0f, 1.0f);
40 CLAMP(ng, 0.0f, 1.0f);
42 chroma = (1.0f -
fabsf(2.0f *
l - 1.0f)) * s;
44 *r_r = (nr - 0.5f) * chroma +
l;
45 *r_g = (ng - 0.5f) * chroma +
l;
46 *r_b = (nb - 0.5f) * chroma +
l;
51 hsv_to_rgb(hsv[0], hsv[1], hsv[2], &r_rgb[0], &r_rgb[1], &r_rgb[2]);
56 hsl_to_rgb(hsl[0], hsl[1], hsl[2], &r_rgb[0], &r_rgb[1], &r_rgb[2]);
59 void rgb_to_yuv(
float r,
float g,
float b,
float *r_y,
float *r_u,
float *r_v,
int colorspace)
65 y = 0.299f *
r + 0.587f *
g + 0.114f *
b;
66 u = -0.147f *
r - 0.289f *
g + 0.436f *
b;
67 v = 0.615f *
r - 0.515f *
g - 0.100f *
b;
72 y = 0.2126f *
r + 0.7152f *
g + 0.0722f *
b;
73 u = -0.09991f *
r - 0.33609f *
g + 0.436f *
b;
74 v = 0.615f *
r - 0.55861f *
g - 0.05639f *
b;
83 void yuv_to_rgb(
float y,
float u,
float v,
float *r_r,
float *r_g,
float *r_b,
int colorspace)
90 g =
y - 0.394f * u - 0.581f *
v;
97 g =
y - 0.21482f * u - 0.38059f *
v;
107 void rgb_to_ycc(
float r,
float g,
float b,
float *r_y,
float *r_cb,
float *r_cr,
int colorspace)
110 float y = 128.0f, cr = 128.0f, cb = 128.0f;
116 switch (colorspace) {
118 y = (0.257f * sr) + (0.504f * sg) + (0.098f * sb) + 16.0f;
119 cb = (-0.148f * sr) - (0.291f * sg) + (0.439f * sb) + 128.0f;
120 cr = (0.439f * sr) - (0.368f * sg) - (0.071f * sb) + 128.0f;
123 y = (0.183f * sr) + (0.614f * sg) + (0.062f * sb) + 16.0f;
124 cb = (-0.101f * sr) - (0.338f * sg) + (0.439f * sb) + 128.0f;
125 cr = (0.439f * sr) - (0.399f * sg) - (0.040f * sb) + 128.0f;
128 y = (0.299f * sr) + (0.587f * sg) + (0.114f * sb);
129 cb = (-0.16874f * sr) - (0.33126f * sg) + (0.5f * sb) + 128.0f;
130 cr = (0.5f * sr) - (0.41869f * sg) - (0.08131f * sb) + 128.0f;
142 void ycc_to_rgb(
float y,
float cb,
float cr,
float *r_r,
float *r_g,
float *r_b,
int colorspace)
150 float r = 128.0f,
g = 128.0f,
b = 128.0f;
152 switch (colorspace) {
154 r = 1.164f * (
y - 16.0f) + 1.596f * (cr - 128.0f);
155 g = 1.164f * (
y - 16.0f) - 0.813f * (cr - 128.0f) - 0.392f * (cb - 128.0f);
156 b = 1.164f * (
y - 16.0f) + 2.017f * (cb - 128.0f);
159 r = 1.164f * (
y - 16.0f) + 1.793f * (cr - 128.0f);
160 g = 1.164f * (
y - 16.0f) - 0.534f * (cr - 128.0f) - 0.213f * (cb - 128.0f);
161 b = 1.164f * (
y - 16.0f) + 2.115f * (cb - 128.0f);
164 r =
y + 1.402f * cr - 179.456f;
165 g =
y - 0.34414f * cb - 0.71414f * cr + 135.45984f;
166 b =
y + 1.772f * cb - 226.816f;
177 void hex_to_rgb(
const char *hexcol,
float *r_r,
float *r_g,
float *r_b)
179 unsigned int ri, gi, bi;
181 if (hexcol[0] ==
'#') {
185 if (sscanf(hexcol,
"%02x%02x%02x", &ri, &gi, &bi) == 3) {
188 else if (sscanf(hexcol,
"%01x%01x%01x", &ri, &gi, &bi) == 3) {
196 *r_r = *r_g = *r_b = 0.0f;
200 *r_r = (
float)ri * (1.0f / 255.0f);
201 *r_g = (
float)gi * (1.0f / 255.0f);
202 *r_b = (
float)bi * (1.0f / 255.0f);
203 CLAMP(*r_r, 0.0f, 1.0f);
204 CLAMP(*r_g, 0.0f, 1.0f);
205 CLAMP(*r_b, 0.0f, 1.0f);
208 void rgb_to_hsv(
float r,
float g,
float b,
float *r_h,
float *r_s,
float *r_v)
221 k = -2.0f / 6.0f - k;
227 *r_h =
fabsf(k + (
g -
b) / (6.0f * chroma + 1e-20f));
228 *r_s = chroma / (
r + 1e-20f);
237 void rgb_to_hsl(
float r,
float g,
float b,
float *r_h,
float *r_s,
float *r_l)
241 float h, s,
l =
min_ff(1.0f, (cmax + cmin) / 2.0f);
247 float d = cmax - cmin;
248 s =
l > 0.5f ? d / (2.0f - cmax - cmin) : d / (cmax + cmin);
250 h = (
g -
b) / d + (
g <
b ? 6.0f : 0.0f);
252 else if (cmax ==
g) {
253 h = (
b -
r) / d + 2.0f;
256 h = (
r -
g) / d + 4.0f;
268 const float orig_s = *r_s;
269 const float orig_h = *r_h;
277 else if (*r_s <= 0.0f) {
282 if (*r_h == 0.0f && orig_h >= 1.0f) {
299 const float orig_h = *r_h;
300 const float orig_s = *r_s;
309 else if (*r_s <= 1
e-8) {
313 if (*r_h == 0.0f && orig_h >= 1.0f) {
325 if (
UNLIKELY(hsv[0] < 0.0f || hsv[0] > 1.0f)) {
326 hsv[0] = hsv[0] -
floorf(hsv[0]);
328 CLAMP(hsv[1], 0.0f, 1.0f);
329 CLAMP(hsv[2], 0.0f, v_max);
334 unsigned int r,
g,
b;
340 r = (
unsigned int)(rf * 255.0f);
341 g = (
unsigned int)(gf * 255.0f);
342 b = (
unsigned int)(bf * 255.0f);
344 col = (
r + (
g * 256) + (
b * 256 * 256));
350 unsigned int ir, ig, ib;
366 return (ir + (ig * 256) + (ib * 256 * 256));
371 *r_r = ((
float)(((
col)) & 0xFF)) * (1.0f / 255.0f);
372 *r_g = ((
float)(((
col) >> 8) & 0xFF)) * (1.0f / 255.0f);
373 *r_b = ((
float)(((
col) >> 16) & 0xFF)) * (1.0f / 255.0f);
378 r_col[0] = ((
float)col_ub[0]) * (1.0f / 255.0f);
379 r_col[1] = ((
float)col_ub[1]) * (1.0f / 255.0f);
380 r_col[2] = ((
float)col_ub[2]) * (1.0f / 255.0f);
385 r_col[0] = ((
float)col_ub[0]) * (1.0f / 255.0f);
386 r_col[1] = ((
float)col_ub[1]) * (1.0f / 255.0f);
387 r_col[2] = ((
float)col_ub[2]) * (1.0f / 255.0f);
388 r_col[3] = ((
float)col_ub[3]) * (1.0f / 255.0f);
406 return (
c < 0.0f) ? 0.0f :
c * (1.0f / 12.92f);
409 return powf((
c + 0.055f) * (1.0f / 1.055f), 2.4f);
414 if (
c < 0.0031308f) {
415 return (
c < 0.0f) ? 0.0f :
c * 12.92f;
418 return 1.055f *
powf(
c, 1.0f / 2.4f) - 0.055f;
472 for (
c = 0;
c < 3;
c++) {
474 slope[
c] = gain[
c] * (1.0f - lift[
c]);
479 power[
c] = 1.0f / gamma[
c];
492 hsv[0] += hue_offset;
496 else if (hsv[0] < 0.0f) {
520 static unsigned short hipart(
const float f)
524 unsigned short us[2];
529 #ifdef __BIG_ENDIAN__
541 unsigned short us[2];
545 if (i < 0x80 || (i >= 0x8000 && i < 0x8080)) {
549 if (i >= 0x7f80 && i < 0x8000) {
556 #ifdef __BIG_ENDIAN__
578 for (i = 0; i < 0x10000; i++) {
592 for (
b = 0;
b <= 255;
b++) {
typedef float(TangentPoint)[2]
#define BLI_assert_unreachable()
#define BLI_assert_msg(a, msg)
MINLINE float max_fff(float a, float b, float c)
MINLINE float max_ff(float a, float b)
MINLINE float min_ffff(float a, float b, float c, float d)
MINLINE float min_ff(float a, float b)
MINLINE float min_fff(float a, float b, float c)
#define BLI_YUV_ITU_BT709
#define BLI_YCC_JFIF_0_255
#define BLI_YCC_ITU_BT601
#define BLI_YUV_ITU_BT601
#define BLI_YCC_ITU_BT709
Strict compiler flags for areas of code we want to ensure don't do conversions without us knowing abo...
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint GLsizei GLsizei GLenum type _GL_VOID_RET _GL_VOID GLsizei GLenum GLenum const void *pixels _GL_VOID_RET _GL_VOID const void *pointer _GL_VOID_RET _GL_VOID GLdouble v _GL_VOID_RET _GL_VOID GLfloat v _GL_VOID_RET _GL_VOID GLint GLint i2 _GL_VOID_RET _GL_VOID GLint j _GL_VOID_RET _GL_VOID GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble GLdouble GLdouble zFar _GL_VOID_RET _GL_UINT GLdouble *equation _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLenum GLfloat *v _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLfloat *values _GL_VOID_RET _GL_VOID GLushort *values _GL_VOID_RET _GL_VOID GLenum GLfloat *params _GL_VOID_RET _GL_VOID GLenum GLdouble *params _GL_VOID_RET _GL_VOID GLenum GLint *params _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_BOOL GLfloat param _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLushort pattern _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLint GLdouble GLdouble GLint GLint const GLdouble *points _GL_VOID_RET _GL_VOID GLdouble GLdouble u2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLint GLdouble GLdouble v2 _GL_VOID_RET _GL_VOID GLenum GLfloat param _GL_VOID_RET _GL_VOID GLenum GLint param _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLdouble GLdouble nz _GL_VOID_RET _GL_VOID GLfloat GLfloat nz _GL_VOID_RET _GL_VOID GLint GLint nz _GL_VOID_RET _GL_VOID GLshort GLshort nz _GL_VOID_RET _GL_VOID GLsizei const void *pointer _GL_VOID_RET _GL_VOID GLsizei const GLfloat *values _GL_VOID_RET _GL_VOID GLsizei const GLushort *values _GL_VOID_RET _GL_VOID GLint param _GL_VOID_RET _GL_VOID const GLuint const GLclampf *priorities _GL_VOID_RET _GL_VOID GLdouble y _GL_VOID_RET _GL_VOID GLfloat y _GL_VOID_RET _GL_VOID GLint y _GL_VOID_RET _GL_VOID GLshort y _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLfloat GLfloat z _GL_VOID_RET _GL_VOID GLint GLint z _GL_VOID_RET _GL_VOID GLshort GLshort z _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble w _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat w _GL_VOID_RET _GL_VOID GLint GLint GLint w _GL_VOID_RET _GL_VOID GLshort GLshort GLshort w _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble y2 _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat y2 _GL_VOID_RET _GL_VOID GLint GLint GLint y2 _GL_VOID_RET _GL_VOID GLshort GLshort GLshort y2 _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLdouble GLdouble z _GL_VOID_RET _GL_VOID GLuint *buffer _GL_VOID_RET _GL_VOID GLdouble t _GL_VOID_RET _GL_VOID GLfloat t _GL_VOID_RET _GL_VOID GLint t _GL_VOID_RET _GL_VOID GLshort t _GL_VOID_RET _GL_VOID GLdouble GLdouble r _GL_VOID_RET _GL_VOID GLfloat GLfloat r _GL_VOID_RET _GL_VOID GLint GLint r _GL_VOID_RET _GL_VOID GLshort GLshort r _GL_VOID_RET _GL_VOID GLdouble GLdouble r
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Bright Control the brightness and contrast of the input color Vector Map an input vectors to used to fine tune the interpolation of the input Camera Retrieve information about the camera and how it relates to the current shading point s position CLAMP
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
ATTR_WARN_UNUSED_RESULT const BMVert * v
SIMD_FORCE_INLINE const btScalar & w() const
Return the w value.
ccl_gpu_kernel_postfix ccl_global float int int int int float bool int offset
#define unit_float_to_uchar_clamp_v4(v1, v2)
#define unit_float_to_uchar_clamp_v3(v1, v2)
void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
void rgb_to_hsl(float r, float g, float b, float *r_h, float *r_s, float *r_l)
void rgb_to_hsl_compat(float r, float g, float b, float *r_h, float *r_s, float *r_l)
void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3])
unsigned int rgb_to_cpack(float r, float g, float b)
unsigned short BLI_color_to_srgb_table[0x10000]
int constrain_rgb(float *r, float *g, float *b)
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
unsigned int hsv_to_cpack(float h, float s, float v)
void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
void BLI_init_srgb_conversion(void)
void ycc_to_rgb(float y, float cb, float cr, float *r_r, float *r_g, float *r_b, int colorspace)
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
void minmax_rgb(short c[3])
void rgb_to_ycc(float r, float g, float b, float *r_y, float *r_cb, float *r_cr, int colorspace)
void rgb_to_yuv(float r, float g, float b, float *r_y, float *r_u, float *r_v, int colorspace)
void rgb_to_hsv_compat(float r, float g, float b, float *r_h, float *r_s, float *r_v)
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
static unsigned short hipart(const float f)
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
void hsv_clamp_v(float hsv[3], float v_max)
void hsl_to_rgb(float h, float s, float l, float *r_r, float *r_g, float *r_b)
void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset)
float srgb_to_linearrgb(float c)
void hex_to_rgb(const char *hexcol, float *r_r, float *r_g, float *r_b)
float BLI_color_from_srgb_table[256]
float linearrgb_to_srgb(float c)
void lift_gamma_gain_to_asc_cdl(const float *lift, const float *gamma, const float *gain, float *offset, float *slope, float *power)
void yuv_to_rgb(float y, float u, float v, float *r_r, float *r_g, float *r_b, int colorspace)
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
void cpack_to_rgb(unsigned int col, float *r_r, float *r_g, float *r_b)
void rgb_to_hsl_compat_v(const float rgb[3], float r_hsl[3])
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
static float index_to_float(const unsigned short i)
void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
static const pxr::TfToken b("b", pxr::TfToken::Immortal)
static const pxr::TfToken g("g", pxr::TfToken::Immortal)
static const pxr::TfToken rgb("rgb", pxr::TfToken::Immortal)