19#ifndef __MATH_COLOR_INLINE_C__
20# define __MATH_COLOR_INLINE_C__
59 float alpha, inv_alpha;
61 if (srgb[3] == 1.0f || srgb[3] == 0.0f) {
67 inv_alpha = 1.0f / alpha;
70 linear[0] = srgb[0] * inv_alpha;
71 linear[1] = srgb[1] * inv_alpha;
72 linear[2] = srgb[2] * inv_alpha;
82 float alpha, inv_alpha;
84 if (linear[3] == 1.0f || linear[3] == 0.0f) {
90 inv_alpha = 1.0f / alpha;
93 srgb[0] = linear[0] * inv_alpha;
94 srgb[1] = linear[1] * inv_alpha;
95 srgb[2] = linear[2] * inv_alpha;
113 unsigned short us[2];
116# ifdef __BIG_ENDIAN__
136 linear[3] = srgb[3] * (1.0f / 255.0f);
144 if (srgb[3] == 255 || srgb[3] == 0) {
149 for (i = 0; i < 4; i++) {
150 fsrgb[i] = srgb[i] * (1.0f / 255.0f);
166 float col[4],
const float r,
const float g,
const float b,
const float a)
187 r_col[0] = ((pack) >> 0) & 0xFF;
188 r_col[1] = ((pack) >> 8) & 0xFF;
189 r_col[2] = ((pack) >> 16) & 0xFF;
205 return (0.2126f * rgb[0]) + (0.7152f * rgb[1]) + (0.0722f * rgb[2]);
210 return (
unsigned char)(((54 * (
unsigned short)rgb[0]) + (182 * (
unsigned short)rgb[1]) +
211 (19 * (
unsigned short)rgb[2])) /
218 const unsigned char col_b[3],
221 const int r = (
int)col_a[0] - (
int)col_b[0];
222 if (
abs(r) < limit) {
223 const int g = (
int)col_a[1] - (
int)col_b[1];
224 if (
abs(g) < limit) {
225 const int b = (
int)col_a[2] - (
int)col_b[2];
226 if (
abs(
b) < limit) {
242 float hash0 =
sinf(s * 12.9898f + t * 78.233f) * 43758.5453f;
243 float hash1 =
sinf(s * 19.9898f + t * 119.233f) * 43798.5453f;
247 return hash0 + hash1 - 0.5f;
251 unsigned char b[3],
const float f[3],
float dither,
float s,
float t)
264 if (premul[3] == 0.0f || premul[3] == 1.0f) {
265 straight[0] = premul[0];
266 straight[1] = premul[1];
267 straight[2] = premul[2];
268 straight[3] = premul[3];
271 const float alpha_inv = 1.0f / premul[3];
272 straight[0] = premul[0] * alpha_inv;
273 straight[1] = premul[1] * alpha_inv;
274 straight[2] = premul[2] * alpha_inv;
275 straight[3] = premul[3];
286 const float alpha = straight[3];
287 premul[0] = straight[0] * alpha;
288 premul[1] = straight[1] * alpha;
289 premul[2] = straight[2] * alpha;
290 premul[3] = straight[3];
300 const float alpha = color[3] * (1.0f / 255.0f);
301 const float fac = alpha * (1.0f / 255.0f);
303 result[0] = color[0] * fac;
304 result[1] = color[1] * fac;
305 result[2] = color[2] * fac;
311 if (color[3] == 0.0f || color[3] == 1.0f) {
318 const float alpha_inv = 1.0f / color[3];
void linearrgb_to_srgb_v3_v3(float srgb[3], const float linear[3])
void srgb_to_linearrgb_v3_v3(float linear[3], const float srgb[3])
local_group_size(16, 16) .push_constant(Type b
draw_view push_constant(Type::INT, "radiance_src") .push_constant(Type capture_info_buf storage_buf(1, Qualifier::READ, "ObjectBounds", "bounds_buf[]") .push_constant(Type draw_view int
#define unit_float_to_ushort_clamp(val)
#define unit_float_to_uchar_clamp(val)
#define unit_float_to_uchar_clamp_v4(v1, v2)
#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 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]
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]
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])
ccl_device_inline int abs(int x)