Blender  V3.3
math_color.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
8 #include "BLI_math.h"
9 #include "BLI_utildefines.h"
10 
11 #include "BLI_strict_flags.h"
12 
13 void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
14 {
15  float nr, ng, nb;
16 
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);
20 
21  CLAMP(nr, 0.0f, 1.0f);
22  CLAMP(nb, 0.0f, 1.0f);
23  CLAMP(ng, 0.0f, 1.0f);
24 
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;
28 }
29 
30 void hsl_to_rgb(float h, float s, float l, float *r_r, float *r_g, float *r_b)
31 {
32  float nr, ng, nb, chroma;
33 
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);
37 
38  CLAMP(nr, 0.0f, 1.0f);
39  CLAMP(nb, 0.0f, 1.0f);
40  CLAMP(ng, 0.0f, 1.0f);
41 
42  chroma = (1.0f - fabsf(2.0f * l - 1.0f)) * s;
43 
44  *r_r = (nr - 0.5f) * chroma + l;
45  *r_g = (ng - 0.5f) * chroma + l;
46  *r_b = (nb - 0.5f) * chroma + l;
47 }
48 
49 void hsv_to_rgb_v(const float hsv[3], float r_rgb[3])
50 {
51  hsv_to_rgb(hsv[0], hsv[1], hsv[2], &r_rgb[0], &r_rgb[1], &r_rgb[2]);
52 }
53 
54 void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
55 {
56  hsl_to_rgb(hsl[0], hsl[1], hsl[2], &r_rgb[0], &r_rgb[1], &r_rgb[2]);
57 }
58 
59 void rgb_to_yuv(float r, float g, float b, float *r_y, float *r_u, float *r_v, int colorspace)
60 {
61  float y, u, v;
62 
63  switch (colorspace) {
64  case BLI_YUV_ITU_BT601:
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;
68  break;
69  case BLI_YUV_ITU_BT709:
70  default:
71  BLI_assert(colorspace == BLI_YUV_ITU_BT709);
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;
75  break;
76  }
77 
78  *r_y = y;
79  *r_u = u;
80  *r_v = v;
81 }
82 
83 void yuv_to_rgb(float y, float u, float v, float *r_r, float *r_g, float *r_b, int colorspace)
84 {
85  float r, g, b;
86 
87  switch (colorspace) {
88  case BLI_YUV_ITU_BT601:
89  r = y + 1.140f * v;
90  g = y - 0.394f * u - 0.581f * v;
91  b = y + 2.032f * u;
92  break;
93  case BLI_YUV_ITU_BT709:
94  default:
95  BLI_assert(colorspace == BLI_YUV_ITU_BT709);
96  r = y + 1.28033f * v;
97  g = y - 0.21482f * u - 0.38059f * v;
98  b = y + 2.12798f * u;
99  break;
100  }
101 
102  *r_r = r;
103  *r_g = g;
104  *r_b = b;
105 }
106 
107 void rgb_to_ycc(float r, float g, float b, float *r_y, float *r_cb, float *r_cr, int colorspace)
108 {
109  float sr, sg, sb;
110  float y = 128.0f, cr = 128.0f, cb = 128.0f;
111 
112  sr = 255.0f * r;
113  sg = 255.0f * g;
114  sb = 255.0f * b;
115 
116  switch (colorspace) {
117  case BLI_YCC_ITU_BT601:
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;
121  break;
122  case BLI_YCC_ITU_BT709:
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;
126  break;
127  case BLI_YCC_JFIF_0_255:
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;
131  break;
132  default:
133  BLI_assert_msg(0, "invalid colorspace");
134  break;
135  }
136 
137  *r_y = y;
138  *r_cb = cb;
139  *r_cr = cr;
140 }
141 
142 void ycc_to_rgb(float y, float cb, float cr, float *r_r, float *r_g, float *r_b, int colorspace)
143 {
144  /* FIXME the following comment must be wrong because:
145  * BLI_YCC_ITU_BT601 y 16.0 cr 16.0 -> r -0.7009. */
146 
147  /* YCC input have a range of 16-235 and 16-240 except with JFIF_0_255 where the range is 0-255
148  * RGB outputs are in the range 0 - 1.0f. */
149 
150  float r = 128.0f, g = 128.0f, b = 128.0f;
151 
152  switch (colorspace) {
153  case BLI_YCC_ITU_BT601:
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);
157  break;
158  case BLI_YCC_ITU_BT709:
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);
162  break;
163  case BLI_YCC_JFIF_0_255:
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;
167  break;
168  default:
170  break;
171  }
172  *r_r = r / 255.0f;
173  *r_g = g / 255.0f;
174  *r_b = b / 255.0f;
175 }
176 
177 void hex_to_rgb(const char *hexcol, float *r_r, float *r_g, float *r_b)
178 {
179  unsigned int ri, gi, bi;
180 
181  if (hexcol[0] == '#') {
182  hexcol++;
183  }
184 
185  if (sscanf(hexcol, "%02x%02x%02x", &ri, &gi, &bi) == 3) {
186  /* six digit hex colors */
187  }
188  else if (sscanf(hexcol, "%01x%01x%01x", &ri, &gi, &bi) == 3) {
189  /* three digit hex colors (#123 becomes #112233) */
190  ri += ri << 4;
191  gi += gi << 4;
192  bi += bi << 4;
193  }
194  else {
195  /* avoid using un-initialized vars */
196  *r_r = *r_g = *r_b = 0.0f;
197  return;
198  }
199 
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);
206 }
207 
208 void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
209 {
210  float k = 0.0f;
211  float chroma;
212  float min_gb;
213 
214  if (g < b) {
215  SWAP(float, g, b);
216  k = -1.0f;
217  }
218  min_gb = b;
219  if (r < g) {
220  SWAP(float, r, g);
221  k = -2.0f / 6.0f - k;
222  min_gb = min_ff(g, b);
223  }
224 
225  chroma = r - min_gb;
226 
227  *r_h = fabsf(k + (g - b) / (6.0f * chroma + 1e-20f));
228  *r_s = chroma / (r + 1e-20f);
229  *r_v = r;
230 }
231 
232 void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
233 {
234  rgb_to_hsv(rgb[0], rgb[1], rgb[2], &r_hsv[0], &r_hsv[1], &r_hsv[2]);
235 }
236 
237 void rgb_to_hsl(float r, float g, float b, float *r_h, float *r_s, float *r_l)
238 {
239  const float cmax = max_fff(r, g, b);
240  const float cmin = min_fff(r, g, b);
241  float h, s, l = min_ff(1.0f, (cmax + cmin) / 2.0f);
242 
243  if (cmax == cmin) {
244  h = s = 0.0f; /* achromatic */
245  }
246  else {
247  float d = cmax - cmin;
248  s = l > 0.5f ? d / (2.0f - cmax - cmin) : d / (cmax + cmin);
249  if (cmax == r) {
250  h = (g - b) / d + (g < b ? 6.0f : 0.0f);
251  }
252  else if (cmax == g) {
253  h = (b - r) / d + 2.0f;
254  }
255  else {
256  h = (r - g) / d + 4.0f;
257  }
258  }
259  h /= 6.0f;
260 
261  *r_h = h;
262  *r_s = s;
263  *r_l = l;
264 }
265 
266 void rgb_to_hsl_compat(float r, float g, float b, float *r_h, float *r_s, float *r_l)
267 {
268  const float orig_s = *r_s;
269  const float orig_h = *r_h;
270 
271  rgb_to_hsl(r, g, b, r_h, r_s, r_l);
272 
273  if (*r_l <= 0.0f) {
274  *r_h = orig_h;
275  *r_s = orig_s;
276  }
277  else if (*r_s <= 0.0f) {
278  *r_h = orig_h;
279  *r_s = orig_s;
280  }
281 
282  if (*r_h == 0.0f && orig_h >= 1.0f) {
283  *r_h = 1.0f;
284  }
285 }
286 
287 void rgb_to_hsl_compat_v(const float rgb[3], float r_hsl[3])
288 {
289  rgb_to_hsl_compat(rgb[0], rgb[1], rgb[2], &r_hsl[0], &r_hsl[1], &r_hsl[2]);
290 }
291 
292 void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
293 {
294  rgb_to_hsl(rgb[0], rgb[1], rgb[2], &r_hsl[0], &r_hsl[1], &r_hsl[2]);
295 }
296 
297 void rgb_to_hsv_compat(float r, float g, float b, float *r_h, float *r_s, float *r_v)
298 {
299  const float orig_h = *r_h;
300  const float orig_s = *r_s;
301 
302  rgb_to_hsv(r, g, b, r_h, r_s, r_v);
303 
304  if (*r_v <= 1e-8) {
305  /* Very low v values will affect the hs values, correct them in post. */
306  *r_h = orig_h;
307  *r_s = orig_s;
308  }
309  else if (*r_s <= 1e-8) {
310  *r_h = orig_h;
311  }
312 
313  if (*r_h == 0.0f && orig_h >= 1.0f) {
314  *r_h = 1.0f;
315  }
316 }
317 
318 void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3])
319 {
320  rgb_to_hsv_compat(rgb[0], rgb[1], rgb[2], &r_hsv[0], &r_hsv[1], &r_hsv[2]);
321 }
322 
323 void hsv_clamp_v(float hsv[3], float v_max)
324 {
325  if (UNLIKELY(hsv[0] < 0.0f || hsv[0] > 1.0f)) {
326  hsv[0] = hsv[0] - floorf(hsv[0]);
327  }
328  CLAMP(hsv[1], 0.0f, 1.0f);
329  CLAMP(hsv[2], 0.0f, v_max);
330 }
331 
332 unsigned int hsv_to_cpack(float h, float s, float v)
333 {
334  unsigned int r, g, b;
335  float rf, gf, bf;
336  unsigned int col;
337 
338  hsv_to_rgb(h, s, v, &rf, &gf, &bf);
339 
340  r = (unsigned int)(rf * 255.0f);
341  g = (unsigned int)(gf * 255.0f);
342  b = (unsigned int)(bf * 255.0f);
343 
344  col = (r + (g * 256) + (b * 256 * 256));
345  return col;
346 }
347 
348 unsigned int rgb_to_cpack(float r, float g, float b)
349 {
350  unsigned int ir, ig, ib;
351 
352  ir = (unsigned int)floorf(255.0f * max_ff(r, 0.0f));
353  ig = (unsigned int)floorf(255.0f * max_ff(g, 0.0f));
354  ib = (unsigned int)floorf(255.0f * max_ff(b, 0.0f));
355 
356  if (ir > 255) {
357  ir = 255;
358  }
359  if (ig > 255) {
360  ig = 255;
361  }
362  if (ib > 255) {
363  ib = 255;
364  }
365 
366  return (ir + (ig * 256) + (ib * 256 * 256));
367 }
368 
369 void cpack_to_rgb(unsigned int col, float *r_r, float *r_g, float *r_b)
370 {
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);
374 }
375 
376 void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
377 {
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);
381 }
382 
383 void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
384 {
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);
389 }
390 
391 void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
392 {
393  unit_float_to_uchar_clamp_v3(r_col, col_f);
394 }
395 
396 void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
397 {
398  unit_float_to_uchar_clamp_v4(r_col, col_f);
399 }
400 
401 /* ********************************* color transforms ********************************* */
402 
403 float srgb_to_linearrgb(float c)
404 {
405  if (c < 0.04045f) {
406  return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
407  }
408 
409  return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
410 }
411 
412 float linearrgb_to_srgb(float c)
413 {
414  if (c < 0.0031308f) {
415  return (c < 0.0f) ? 0.0f : c * 12.92f;
416  }
417 
418  return 1.055f * powf(c, 1.0f / 2.4f) - 0.055f;
419 }
420 
421 void minmax_rgb(short c[3])
422 {
423  if (c[0] > 255) {
424  c[0] = 255;
425  }
426  else if (c[0] < 0) {
427  c[0] = 0;
428  }
429 
430  if (c[1] > 255) {
431  c[1] = 255;
432  }
433  else if (c[1] < 0) {
434  c[1] = 0;
435  }
436 
437  if (c[2] > 255) {
438  c[2] = 255;
439  }
440  else if (c[2] < 0) {
441  c[2] = 0;
442  }
443 }
444 
445 int constrain_rgb(float *r, float *g, float *b)
446 {
447  /* Amount of white needed */
448  const float w = -min_ffff(0.0f, *r, *g, *b);
449 
450  /* Add just enough white to make r, g, b all positive. */
451  if (w > 0.0f) {
452  *r += w;
453  *g += w;
454  *b += w;
455 
456  return 1; /* Color modified to fit RGB gamut */
457  }
458 
459  return 0; /* Color within RGB gamut */
460 }
461 
462 /* ********************** lift/gamma/gain / ASC-CDL conversion ********************************* */
463 
464 void lift_gamma_gain_to_asc_cdl(const float *lift,
465  const float *gamma,
466  const float *gain,
467  float *offset,
468  float *slope,
469  float *power)
470 {
471  int c;
472  for (c = 0; c < 3; c++) {
473  offset[c] = lift[c] * gain[c];
474  slope[c] = gain[c] * (1.0f - lift[c]);
475  if (gamma[c] == 0) {
476  power[c] = FLT_MAX;
477  }
478  else {
479  power[c] = 1.0f / gamma[c];
480  }
481  }
482 }
483 
484 /* ************************************* other ************************************************* */
485 
486 void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
487 {
488  float hsv[3];
489 
490  rgb_to_hsv(rgb[0], rgb[1], rgb[2], hsv, hsv + 1, hsv + 2);
491 
492  hsv[0] += hue_offset;
493  if (hsv[0] > 1.0f) {
494  hsv[0] -= 1.0f;
495  }
496  else if (hsv[0] < 0.0f) {
497  hsv[0] += 1.0f;
498  }
499 
500  hsv_to_rgb(hsv[0], hsv[1], hsv[2], rgb, rgb + 1, rgb + 2);
501 }
502 
503 void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset)
504 {
505  float rgb_float[3];
506 
507  rgb_uchar_to_float(rgb_float, rgb);
508  rgb_float_set_hue_float_offset(rgb_float, hue_offset);
509  rgb_float_to_uchar(rgb, rgb_float);
510 }
511 
512 /* fast sRGB conversion
513  * LUT from linear float to 16-bit short
514  * based on http://mysite.verizon.net/spitzak/conversion/
515  */
516 
518 unsigned short BLI_color_to_srgb_table[0x10000];
519 
520 static unsigned short hipart(const float f)
521 {
522  union {
523  float f;
524  unsigned short us[2];
525  } tmp;
526 
527  tmp.f = f;
528 
529 #ifdef __BIG_ENDIAN__
530  return tmp.us[0];
531 #else
532  return tmp.us[1];
533 #endif
534 }
535 
536 static float index_to_float(const unsigned short i)
537 {
538 
539  union {
540  float f;
541  unsigned short us[2];
542  } tmp;
543 
544  /* positive and negative zeros, and all gradual underflow, turn into zero: */
545  if (i < 0x80 || (i >= 0x8000 && i < 0x8080)) {
546  return 0;
547  }
548  /* All NaN's and infinity turn into the largest possible legal float: */
549  if (i >= 0x7f80 && i < 0x8000) {
550  return FLT_MAX;
551  }
552  if (i >= 0xff80) {
553  return -FLT_MAX;
554  }
555 
556 #ifdef __BIG_ENDIAN__
557  tmp.us[0] = i;
558  tmp.us[1] = 0x8000;
559 #else
560  tmp.us[0] = 0x8000;
561  tmp.us[1] = i;
562 #endif
563 
564  return tmp.f;
565 }
566 
568 {
569  static bool initialized = false;
570  unsigned int i, b;
571 
572  if (initialized) {
573  return;
574  }
575  initialized = true;
576 
577  /* Fill in the lookup table to convert floats to bytes: */
578  for (i = 0; i < 0x10000; i++) {
579  float f = linearrgb_to_srgb(index_to_float((unsigned short)i)) * 255.0f;
580  if (f <= 0) {
582  }
583  else if (f < 255) {
584  BLI_color_to_srgb_table[i] = (unsigned short)(f * 0x100 + 0.5f);
585  }
586  else {
587  BLI_color_to_srgb_table[i] = 0xff00;
588  }
589  }
590 
591  /* Fill in the lookup table to convert bytes to float: */
592  for (b = 0; b <= 255; b++) {
593  float f = srgb_to_linearrgb(((float)b) * (1.0f / 255.0f));
595  i = hipart(f);
596  /* replace entries so byte->float->byte does not change the data: */
597  BLI_color_to_srgb_table[i] = (unsigned short)(b * 0x100);
598  }
599 }
typedef float(TangentPoint)[2]
#define BLI_assert_unreachable()
Definition: BLI_assert.h:93
#define BLI_assert(a)
Definition: BLI_assert.h:46
#define BLI_assert_msg(a, msg)
Definition: BLI_assert.h:53
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...
#define SWAP(type, a, b)
#define UNLIKELY(x)
_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.
Definition: btQuadWord.h:119
#define powf(x, y)
Definition: cuda/compat.h:103
uint col
static bool initialized
Definition: gpu_init_exit.c:22
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])
Definition: math_color.c:49
void rgb_to_hsv_v(const float rgb[3], float r_hsv[3])
Definition: math_color.c:232
void rgb_to_hsl(float r, float g, float b, float *r_h, float *r_s, float *r_l)
Definition: math_color.c:237
void rgb_to_hsl_compat(float r, float g, float b, float *r_h, float *r_s, float *r_l)
Definition: math_color.c:266
void rgb_to_hsv_compat_v(const float rgb[3], float r_hsv[3])
Definition: math_color.c:318
unsigned int rgb_to_cpack(float r, float g, float b)
Definition: math_color.c:348
unsigned short BLI_color_to_srgb_table[0x10000]
Definition: math_color.c:518
int constrain_rgb(float *r, float *g, float *b)
Definition: math_color.c:445
void rgb_to_hsv(float r, float g, float b, float *r_h, float *r_s, float *r_v)
Definition: math_color.c:208
unsigned int hsv_to_cpack(float h, float s, float v)
Definition: math_color.c:332
void hsl_to_rgb_v(const float hsl[3], float r_rgb[3])
Definition: math_color.c:54
void BLI_init_srgb_conversion(void)
Definition: math_color.c:567
void ycc_to_rgb(float y, float cb, float cr, float *r_r, float *r_g, float *r_b, int colorspace)
Definition: math_color.c:142
void hsv_to_rgb(float h, float s, float v, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:13
void minmax_rgb(short c[3])
Definition: math_color.c:421
void rgb_to_ycc(float r, float g, float b, float *r_y, float *r_cb, float *r_cr, int colorspace)
Definition: math_color.c:107
void rgb_to_yuv(float r, float g, float b, float *r_y, float *r_u, float *r_v, int colorspace)
Definition: math_color.c:59
void rgb_to_hsv_compat(float r, float g, float b, float *r_h, float *r_s, float *r_v)
Definition: math_color.c:297
void rgba_uchar_to_float(float r_col[4], const unsigned char col_ub[4])
Definition: math_color.c:383
static unsigned short hipart(const float f)
Definition: math_color.c:520
void rgba_float_to_uchar(unsigned char r_col[4], const float col_f[4])
Definition: math_color.c:396
void hsv_clamp_v(float hsv[3], float v_max)
Definition: math_color.c:323
void hsl_to_rgb(float h, float s, float l, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:30
void rgb_byte_set_hue_float_offset(unsigned char rgb[3], float hue_offset)
Definition: math_color.c:503
float srgb_to_linearrgb(float c)
Definition: math_color.c:403
void hex_to_rgb(const char *hexcol, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:177
float BLI_color_from_srgb_table[256]
Definition: math_color.c:517
float linearrgb_to_srgb(float c)
Definition: math_color.c:412
void lift_gamma_gain_to_asc_cdl(const float *lift, const float *gamma, const float *gain, float *offset, float *slope, float *power)
Definition: math_color.c:464
void yuv_to_rgb(float y, float u, float v, float *r_r, float *r_g, float *r_b, int colorspace)
Definition: math_color.c:83
void rgb_to_hsl_v(const float rgb[3], float r_hsl[3])
Definition: math_color.c:292
void rgb_uchar_to_float(float r_col[3], const unsigned char col_ub[3])
Definition: math_color.c:376
void cpack_to_rgb(unsigned int col, float *r_r, float *r_g, float *r_b)
Definition: math_color.c:369
void rgb_to_hsl_compat_v(const float rgb[3], float r_hsl[3])
Definition: math_color.c:287
void rgb_float_to_uchar(unsigned char r_col[3], const float col_f[3])
Definition: math_color.c:391
static float index_to_float(const unsigned short i)
Definition: math_color.c:536
void rgb_float_set_hue_float_offset(float rgb[3], float hue_offset)
Definition: math_color.c:486
#define floorf(x)
Definition: metal/compat.h:224
#define fabsf(x)
Definition: metal/compat.h:219
static unsigned c
Definition: RandGen.cpp:83
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)