Blender  V3.3
math_color_inline.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_base.h"
9 #include "BLI_math_color.h"
10 #include "BLI_utildefines.h"
11 
12 #include <math.h>
13 
14 #ifndef __MATH_COLOR_INLINE_C__
15 # define __MATH_COLOR_INLINE_C__
16 
17 /******************************** Color Space ********************************/
18 
19 # ifdef BLI_HAVE_SSE2
20 
21 MALWAYS_INLINE __m128 srgb_to_linearrgb_v4_simd(const __m128 c)
22 {
23  __m128 cmp = _mm_cmplt_ps(c, _mm_set1_ps(0.04045f));
24  __m128 lt = _mm_max_ps(_mm_mul_ps(c, _mm_set1_ps(1.0f / 12.92f)), _mm_set1_ps(0.0f));
25  __m128 gtebase = _mm_mul_ps(_mm_add_ps(c, _mm_set1_ps(0.055f)),
26  _mm_set1_ps(1.0f / 1.055f)); /* FMA. */
27  __m128 gte = _bli_math_fastpow24(gtebase);
28  return _bli_math_blend_sse(cmp, lt, gte);
29 }
30 
31 MALWAYS_INLINE __m128 linearrgb_to_srgb_v4_simd(const __m128 c)
32 {
33  __m128 cmp = _mm_cmplt_ps(c, _mm_set1_ps(0.0031308f));
34  __m128 lt = _mm_max_ps(_mm_mul_ps(c, _mm_set1_ps(12.92f)), _mm_set1_ps(0.0f));
35  __m128 gte = _mm_add_ps(_mm_mul_ps(_mm_set1_ps(1.055f), _bli_math_fastpow512(c)),
36  _mm_set1_ps(-0.055f));
37  return _bli_math_blend_sse(cmp, lt, gte);
38 }
39 
40 MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
41 {
42  float r[4] = {srgb[0], srgb[1], srgb[2], 1.0f};
43  __m128 *rv = (__m128 *)&r;
44  *rv = srgb_to_linearrgb_v4_simd(*rv);
45  linear[0] = r[0];
46  linear[1] = r[1];
47  linear[2] = r[2];
48 }
49 
50 MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
51 {
52  float r[4] = {linear[0], linear[1], linear[2], 1.0f};
53  __m128 *rv = (__m128 *)&r;
54  *rv = linearrgb_to_srgb_v4_simd(*rv);
55  srgb[0] = r[0];
56  srgb[1] = r[1];
57  srgb[2] = r[2];
58 }
59 
60 # else /* BLI_HAVE_SSE2 */
61 
62 MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
63 {
64  linear[0] = srgb_to_linearrgb(srgb[0]);
65  linear[1] = srgb_to_linearrgb(srgb[1]);
66  linear[2] = srgb_to_linearrgb(srgb[2]);
67 }
68 
69 MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
70 {
71  srgb[0] = linearrgb_to_srgb(linear[0]);
72  srgb[1] = linearrgb_to_srgb(linear[1]);
73  srgb[2] = linearrgb_to_srgb(linear[2]);
74 }
75 # endif /* BLI_HAVE_SSE2 */
76 
77 MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
78 {
79  srgb_to_linearrgb_v3_v3(linear, srgb);
80  linear[3] = srgb[3];
81 }
82 
83 MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
84 {
85  linearrgb_to_srgb_v3_v3(srgb, linear);
86  srgb[3] = linear[3];
87 }
88 
89 MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3])
90 {
91  float srgb_f[3];
92 
93  linearrgb_to_srgb_v3_v3(srgb_f, linear);
94  unit_float_to_uchar_clamp_v3(srgb, srgb_f);
95 }
96 
97 MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
98 {
99  float srgb_f[4];
100 
101  linearrgb_to_srgb_v4(srgb_f, linear);
102  unit_float_to_uchar_clamp_v4(srgb, srgb_f);
103 }
104 
105 /* predivide versions to work on associated/pre-multiplied alpha. if this should
106  * be done or not depends on the background the image will be composited over,
107  * ideally you would never do color space conversion on an image with alpha
108  * because it is ill defined */
109 
110 MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4])
111 {
112  float alpha, inv_alpha;
113 
114  if (srgb[3] == 1.0f || srgb[3] == 0.0f) {
115  alpha = 1.0f;
116  inv_alpha = 1.0f;
117  }
118  else {
119  alpha = srgb[3];
120  inv_alpha = 1.0f / alpha;
121  }
122 
123  linear[0] = srgb[0] * inv_alpha;
124  linear[1] = srgb[1] * inv_alpha;
125  linear[2] = srgb[2] * inv_alpha;
126  linear[3] = srgb[3];
127  srgb_to_linearrgb_v3_v3(linear, linear);
128  linear[0] *= alpha;
129  linear[1] *= alpha;
130  linear[2] *= alpha;
131 }
132 
133 MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4])
134 {
135  float alpha, inv_alpha;
136 
137  if (linear[3] == 1.0f || linear[3] == 0.0f) {
138  alpha = 1.0f;
139  inv_alpha = 1.0f;
140  }
141  else {
142  alpha = linear[3];
143  inv_alpha = 1.0f / alpha;
144  }
145 
146  srgb[0] = linear[0] * inv_alpha;
147  srgb[1] = linear[1] * inv_alpha;
148  srgb[2] = linear[2] * inv_alpha;
149  srgb[3] = linear[3];
150  linearrgb_to_srgb_v3_v3(srgb, srgb);
151  srgb[0] *= alpha;
152  srgb[1] *= alpha;
153  srgb[2] *= alpha;
154 }
155 
156 /* LUT accelerated conversions */
157 
158 extern float BLI_color_from_srgb_table[256];
159 extern unsigned short BLI_color_to_srgb_table[0x10000];
160 
161 MINLINE unsigned short to_srgb_table_lookup(const float f)
162 {
163 
164  union {
165  float f;
166  unsigned short us[2];
167  } tmp;
168  tmp.f = f;
169 # ifdef __BIG_ENDIAN__
170  return BLI_color_to_srgb_table[tmp.us[0]];
171 # else
172  return BLI_color_to_srgb_table[tmp.us[1]];
173 # endif
174 }
175 
176 MINLINE void linearrgb_to_srgb_ushort4(unsigned short srgb[4], const float linear[4])
177 {
178  srgb[0] = to_srgb_table_lookup(linear[0]);
179  srgb[1] = to_srgb_table_lookup(linear[1]);
180  srgb[2] = to_srgb_table_lookup(linear[2]);
181  srgb[3] = unit_float_to_ushort_clamp(linear[3]);
182 }
183 
184 MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
185 {
186  linear[0] = BLI_color_from_srgb_table[srgb[0]];
187  linear[1] = BLI_color_from_srgb_table[srgb[1]];
188  linear[2] = BLI_color_from_srgb_table[srgb[2]];
189  linear[3] = srgb[3] * (1.0f / 255.0f);
190 }
191 
192 MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned char srgb[4])
193 {
194  float fsrgb[4];
195  int i;
196 
197  if (srgb[3] == 255 || srgb[3] == 0) {
198  srgb_to_linearrgb_uchar4(linear, srgb);
199  return;
200  }
201 
202  for (i = 0; i < 4; i++) {
203  fsrgb[i] = srgb[i] * (1.0f / 255.0f);
204  }
205 
206  srgb_to_linearrgb_predivide_v4(linear, fsrgb);
207 }
208 
210  uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a)
211 {
212  col[0] = r;
213  col[1] = g;
214  col[2] = b;
215  col[3] = a;
216 }
217 
219  float col[4], const float r, const float g, const float b, const float a)
220 {
221  col[0] = r;
222  col[1] = g;
223  col[2] = b;
224  col[3] = a;
225 }
226 
228  uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a)
229 {
230  if (col[3] == 0) {
231  col[0] = r;
232  col[1] = g;
233  col[2] = b;
234  col[3] = a;
235  }
236 }
237 
238 MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
239 {
240  r_col[0] = ((pack) >> 0) & 0xFF;
241  r_col[1] = ((pack) >> 8) & 0xFF;
242  r_col[2] = ((pack) >> 16) & 0xFF;
243 }
244 
245 /* -------------------------------------------------------------------- */
256 MINLINE float rgb_to_grayscale(const float rgb[3])
257 {
258  return (0.2126f * rgb[0]) + (0.7152f * rgb[1]) + (0.0722f * rgb[2]);
259 }
260 
261 MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
262 {
263  return (unsigned char)(((54 * (unsigned short)rgb[0]) + (182 * (unsigned short)rgb[1]) +
264  (19 * (unsigned short)rgb[2])) /
265  255);
266 }
267 
270 MINLINE int compare_rgb_uchar(const unsigned char col_a[3],
271  const unsigned char col_b[3],
272  const int limit)
273 {
274  const int r = (int)col_a[0] - (int)col_b[0];
275  if (abs(r) < limit) {
276  const int g = (int)col_a[1] - (int)col_b[1];
277  if (abs(g) < limit) {
278  const int b = (int)col_a[2] - (int)col_b[2];
279  if (abs(b) < limit) {
280  return 1;
281  }
282  }
283  }
284 
285  return 0;
286 }
287 
288 MINLINE float dither_random_value(float s, float t)
289 {
290  /* Using a triangle distribution which gives a more final uniform noise.
291  * See Banding in Games:A Noisy Rant(revision 5) Mikkel Gjøl, Playdead (slide 27) */
292 
293  /* Uniform noise in [0..1[ range, using common GLSL hash function.
294  * https://stackoverflow.com/questions/12964279/whats-the-origin-of-this-glsl-rand-one-liner. */
295  float hash0 = sinf(s * 12.9898f + t * 78.233f) * 43758.5453f;
296  float hash1 = sinf(s * 19.9898f + t * 119.233f) * 43798.5453f;
297  hash0 -= floorf(hash0);
298  hash1 -= floorf(hash1);
299  /* Convert uniform distribution into triangle-shaped distribution. */
300  return hash0 + hash1 - 0.5f;
301 }
302 
304  unsigned char b[3], const float f[3], float dither, float s, float t)
305 {
306  float dither_value = dither_random_value(s, t) * 0.0033f * dither;
307 
308  b[0] = unit_float_to_uchar_clamp(dither_value + f[0]);
309  b[1] = unit_float_to_uchar_clamp(dither_value + f[1]);
310  b[2] = unit_float_to_uchar_clamp(dither_value + f[2]);
311 }
312 
313 /**************** Alpha Transformations *****************/
314 
315 MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
316 {
317  if (premul[3] == 0.0f || premul[3] == 1.0f) {
318  straight[0] = premul[0];
319  straight[1] = premul[1];
320  straight[2] = premul[2];
321  straight[3] = premul[3];
322  }
323  else {
324  const float alpha_inv = 1.0f / premul[3];
325  straight[0] = premul[0] * alpha_inv;
326  straight[1] = premul[1] * alpha_inv;
327  straight[2] = premul[2] * alpha_inv;
328  straight[3] = premul[3];
329  }
330 }
331 
333 {
335 }
336 
337 MINLINE void straight_to_premul_v4_v4(float premul[4], const float straight[4])
338 {
339  const float alpha = straight[3];
340  premul[0] = straight[0] * alpha;
341  premul[1] = straight[1] * alpha;
342  premul[2] = straight[2] * alpha;
343  premul[3] = straight[3];
344 }
345 
347 {
349 }
350 
351 MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
352 {
353  const float alpha = color[3] * (1.0f / 255.0f);
354  const float fac = alpha * (1.0f / 255.0f);
355 
356  result[0] = color[0] * fac;
357  result[1] = color[1] * fac;
358  result[2] = color[2] * fac;
359  result[3] = alpha;
360 }
361 
362 MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
363 {
364  if (color[3] == 0.0f || color[3] == 1.0f) {
369  }
370  else {
371  const float alpha_inv = 1.0f / color[3];
372 
373  /* hopefully this would be optimized */
374  result[0] = unit_float_to_uchar_clamp(color[0] * alpha_inv);
375  result[1] = unit_float_to_uchar_clamp(color[1] * alpha_inv);
376  result[2] = unit_float_to_uchar_clamp(color[2] * alpha_inv);
378  }
379 }
380 
381 #endif /* __MATH_COLOR_INLINE_C__ */
float srgb_to_linearrgb(float c)
Definition: math_color.c:403
float linearrgb_to_srgb(float c)
Definition: math_color.c:412
#define MALWAYS_INLINE
#define MINLINE
unsigned char uchar
Definition: BLI_sys_types.h:70
_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 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 t
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 a value between a minimum and a maximum Vector Perform vector math operation Invert a color
#define sinf(x)
Definition: cuda/compat.h:102
uint col
MINLINE unsigned char unit_float_to_uchar_clamp(float val)
#define unit_float_to_uchar_clamp_v4(v1, v2)
MINLINE unsigned short unit_float_to_ushort_clamp(float val)
#define unit_float_to_uchar_clamp_v3(v1, v2)
MINLINE void straight_to_premul_v4_v4(float premul[4], const float straight[4])
MINLINE void srgb_to_linearrgb_uchar4_predivide(float linear[4], const unsigned char srgb[4])
MINLINE void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
MINLINE void rgba_uchar_args_set(uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a)
MINLINE unsigned char rgb_to_grayscale_byte(const unsigned char rgb[3])
MINLINE void straight_uchar_to_premul_float(float result[4], const unsigned char color[4])
MINLINE void premul_to_straight_v4(float color[4])
unsigned short BLI_color_to_srgb_table[0x10000]
Definition: math_color.c:518
MINLINE void straight_to_premul_v4(float color[4])
MINLINE void rgba_float_args_set(float col[4], const float r, const float g, const float b, const float a)
MINLINE void linearrgb_to_srgb_ushort4(unsigned short srgb[4], const float linear[4])
MINLINE void cpack_cpy_3ub(unsigned char r_col[3], const unsigned int pack)
MINLINE float rgb_to_grayscale(const float rgb[3])
MINLINE void linearrgb_to_srgb_predivide_v4(float srgb[4], const float linear[4])
MINLINE void srgb_to_linearrgb_uchar4(float linear[4], const unsigned char srgb[4])
MINLINE int compare_rgb_uchar(const unsigned char col_a[3], const unsigned char col_b[3], const int limit)
MINLINE void srgb_to_linearrgb_v4(float linear[4], const float srgb[4])
MINLINE void float_to_byte_dither_v3(unsigned char b[3], const float f[3], float dither, float s, float t)
MINLINE void premul_to_straight_v4_v4(float straight[4], const float premul[4])
MINLINE void linearrgb_to_srgb_uchar4(unsigned char srgb[4], const float linear[4])
MINLINE void rgba_uchar_args_test_set(uchar col[4], const uchar r, const uchar g, const uchar b, const uchar a)
float BLI_color_from_srgb_table[256]
Definition: math_color.c:517
MINLINE void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
MINLINE unsigned short to_srgb_table_lookup(const float f)
MINLINE void linearrgb_to_srgb_v4(float srgb[4], const float linear[4])
MINLINE void linearrgb_to_srgb_uchar3(unsigned char srgb[3], const float linear[3])
MINLINE void srgb_to_linearrgb_predivide_v4(float linear[4], const float srgb[4])
MINLINE float dither_random_value(float s, float t)
MINLINE void premul_float_to_straight_uchar(unsigned char *result, const float color[4])
#define floorf(x)
Definition: metal/compat.h:224
static unsigned c
Definition: RandGen.cpp:83
static unsigned a[3]
Definition: RandGen.cpp:78
T abs(const T &a)
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)