5#ifndef __UTIL_COLOR_H__
6#define __UTIL_COLOR_H__
11#if !defined(__KERNEL_GPU__) && defined(__KERNEL_SSE2__)
19 return ((val <= 0.0f) ? 0 :
20 ((val > (1.0f - 0.5f / 255.0f)) ? 255 : (
uchar)((255.0f * val) + 0.5f)));
25 return val * (1.0f / 255.0f);
53 return make_float3(c.
x * (1.0f / 255.0f), c.
y * (1.0f / 255.0f), c.
z * (1.0f / 255.0f));
59 c.
x * (1.0f / 255.0f), c.
y * (1.0f / 255.0f), c.
z * (1.0f / 255.0f), c.
w * (1.0f / 255.0f));
65 return (c < 0.0f) ? 0.0f : c * (1.0f / 12.92f);
68 return powf((c + 0.055f) * (1.0f / 1.055f), 2.4f);
75 return (c < 0.0f) ? 0.0f : c * 12.92f;
78 return 1.055f *
powf(c, 1.0f / 2.4f) - 0.055f;
84 float cmax, cmin, h, s,
v, cdelta;
103 c = (cmax3 - rgb) / cdelta;
108 else if (rgb.
y == cmax) {
109 h = 2.0f + c.
x - c.
z;
112 h = 4.0f + c.
y - c.
x;
130 float i, f, p, q, t, h, s,
v;
147 q =
v * (1.0f - (s * f));
148 t =
v * (1.0f - (s * (1.0f - f)));
153 else if (i == 1.0f) {
156 else if (i == 2.0f) {
159 else if (i == 3.0f) {
162 else if (i == 4.0f) {
178 float cmax, cmin, h, s,
l;
182 l =
min(1.0f, (cmax + cmin) / 2.0f);
188 float cdelta = cmax - cmin;
189 s =
l > 0.5f ? cdelta / (2.0f - cmax - cmin) : cdelta / (cmax + cmin);
191 h = (rgb.
y - rgb.
z) / cdelta + (rgb.
y < rgb.
z ? 6.0f : 0.0f);
193 else if (cmax == rgb.
y) {
194 h = (rgb.
z - rgb.
x) / cdelta + 2.0f;
197 h = (rgb.
x - rgb.
y) / cdelta + 4.0f;
207 float nr, ng, nb, chroma, h, s,
l;
213 nr =
fabsf(h * 6.0f - 3.0f) - 1.0f;
214 ng = 2.0f -
fabsf(h * 6.0f - 2.0f);
215 nb = 2.0f -
fabsf(h * 6.0f - 4.0f);
217 nr =
clamp(nr, 0.0f, 1.0f);
218 nb =
clamp(nb, 0.0f, 1.0f);
219 ng =
clamp(ng, 0.0f, 1.0f);
221 chroma = (1.0f -
fabsf(2.0f *
l - 1.0f)) * s;
223 return make_float3((nr - 0.5f) * chroma +
l, (ng - 0.5f) * chroma +
l, (nb - 0.5f) * chroma +
l);
237 if (
y != 0.0f &&
Y != 0.0f) {
238 Z = (1.0f -
x -
y) /
y *
Y;
247#ifdef __KERNEL_SSE2__
268 float4 approx2 = old_result * old_result;
269 float4 approx4 = approx2 * approx2;
284 float4 x = fastpow_sse2<0x3F4CCCCD, 0x4F55A7FB>(
287 float4 arg4 = arg2 * arg2;
290 x = improve_5throot_solution_sse2(
x, arg4);
292 x = improve_5throot_solution_sse2(
x, arg4);
294 x = improve_5throot_solution_sse2(
x, arg4);
304 float4 gte = fastpow24_sse2(gtebase);
305 return select(cmp, lt, gte);
329#ifdef __KERNEL_SSE2__
331 r = color_srgb_to_linear_sse2(r);
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 Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves 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 Invert a color
ATTR_WARN_UNUSED_RESULT const BMLoop * l
ATTR_WARN_UNUSED_RESULT const BMVert * v
local_group_size(16, 16) .push_constant(Type b
#define ccl_device_inline
#define CCL_NAMESPACE_END
CCL_NAMESPACE_BEGIN ccl_device_inline float madd(const float a, const float b, const float c)
ccl_device_inline float3 one_float3()
ccl_device_inline float3 exp(float3 v)
ccl_device_inline float3 log(float3 v)
ccl_device_inline int4 cast(const float4 a)
ccl_device_inline float4 select(const int4 mask, const float4 a, const float4 b)
VecBase< float, 4 > float4
ccl_device float3 hsl_to_rgb(float3 hsl)
ccl_device float color_linear_to_srgb(float c)
ccl_device float3 color_highlight_compress(float3 color, ccl_private float3 *variance)
ccl_device float3 xyY_to_xyz(float x, float y, float Y)
ccl_device_inline float4 color_uchar4_to_float4(uchar4 c)
ccl_device uchar4 color_float4_to_uchar4(float4 c)
ccl_device float3 color_srgb_to_linear_v3(float3 c)
ccl_device float4 color_linear_to_srgb_v4(float4 c)
ccl_device float3 rgb_to_hsv(float3 rgb)
ccl_device float3 color_highlight_uncompress(float3 color)
ccl_device float4 color_srgb_to_linear_v4(float4 c)
ccl_device float3 color_linear_to_srgb_v3(float3 c)
ccl_device float3 hsv_to_rgb(float3 hsv)
ccl_device float color_srgb_to_linear(float c)
ccl_device float byte_to_float(uchar val)
ccl_device float3 rgb_to_hsl(float3 rgb)
ccl_device_inline float3 color_byte_to_float(uchar4 c)
ccl_device uchar4 color_float_to_byte(float3 c)
CCL_NAMESPACE_BEGIN ccl_device uchar float_to_byte(float val)
ccl_device_inline float sqr(float a)
ccl_device_inline int clamp(int a, int mn, int mx)