36 AI_DEVICE constexpr
explicit AtRGB(
float c) : r(c), g(c), b(c) { }
37 AI_DEVICE constexpr AtRGB(
float r,
float g,
float b) : r(r), g(g), b(b) { }
38 AI_DEVICE constexpr
explicit AtRGB(
const AtRGBA& rgba);
40 AI_DEVICE constexpr AtRGB operator+(
const AtRGB& rgb)
const
42 return AtRGB(r + rgb.r,
47 AI_DEVICE AtRGB& operator+=(
const AtRGB& rgb)
55 AI_DEVICE constexpr AtRGB operator+(
float f)
const
62 AI_DEVICE AtRGB& operator+=(
float f)
70 AI_DEVICE constexpr AtRGB operator-(
const AtRGB& rgb)
const
72 return AtRGB(r - rgb.r,
77 AI_DEVICE AtRGB& operator-=(
const AtRGB& rgb)
85 AI_DEVICE constexpr AtRGB operator-(
float f)
const
92 AI_DEVICE AtRGB& operator-=(
float f)
100 AI_DEVICE constexpr AtRGB operator-()
const
102 return AtRGB(-r, -g, -b);
105 AI_DEVICE constexpr AtRGB operator*(
const AtRGB& rgb)
const
107 return AtRGB(r * rgb.r,
112 AI_DEVICE AtRGB operator*=(
const AtRGB& rgb)
120 AI_DEVICE constexpr AtRGB operator*(
float f)
const
127 AI_DEVICE AtRGB operator*=(
float f)
135 AI_DEVICE constexpr AtRGB operator/(
const AtRGB& rgb)
const
137 return AtRGB(r / rgb.r,
142 AI_DEVICE AtRGB operator/=(
const AtRGB& rgb)
150 AI_DEVICE AtRGB operator/(
float f)
const
157 AI_DEVICE AtRGB operator/=(
float f)
165 AI_DEVICE constexpr
bool operator==(
const AtRGB& rgb)
const
167 return (r == rgb.r && g == rgb.g && b == rgb.b);
170 AI_DEVICE constexpr
bool operator!=(
const AtRGB& rgb)
const
172 return !(*
this == rgb);
175 AI_DEVICE AtRGB& operator=(
float f)
183 AI_DEVICE
float& operator[](
unsigned int i)
188 AI_DEVICE constexpr
const float& operator[](
unsigned int i)
const
193 AI_DEVICE
friend constexpr AtRGB operator*(
float f,
const AtRGB& rgb);
194 AI_DEVICE
friend constexpr AtRGB operator+(
float f,
const AtRGB& rgb);
195 AI_DEVICE
friend constexpr AtRGB operator-(
float f,
const AtRGB& rgb);
198 AI_DEVICE
inline constexpr
AtRGB operator*(
float f,
const AtRGB& rgb)
203 AI_DEVICE
inline constexpr
AtRGB operator+(
float f,
const AtRGB& rgb)
208 AI_DEVICE
inline constexpr
AtRGB operator-(
float f,
const AtRGB& rgb)
210 return AtRGB(f - rgb.r,
215 AI_DEVICE
inline constexpr
AtRGB operator/(
float f,
const AtRGB& rgb)
217 return AtRGB(f / rgb.r,
271 AI_DEVICE constexpr
AtRGBA(
float r,
float g,
float b,
float a) : r(r), g(g), b(b), a(a) { }
272 AI_DEVICE constexpr AtRGBA(
const AtRGB& rgb,
float a=1) : r(rgb.r), g(rgb.g), b(rgb.b), a(a) { }
274 AI_DEVICE
AtRGB& rgb()
276 return *
static_cast<AtRGB*
>(
static_cast<void*
>(
this));
279 AI_DEVICE
const AtRGB& rgb()
const
281 return *
static_cast<const AtRGB*
>(
static_cast<const void*
>(
this));
284 AI_DEVICE constexpr AtRGBA operator+(
const AtRGBA& rgba)
const
286 return AtRGBA(r + rgba.r,
292 AI_DEVICE AtRGBA& operator+=(
const AtRGBA& rgba)
301 AI_DEVICE constexpr AtRGBA operator+(
float f)
const
309 AI_DEVICE AtRGBA& operator+=(
float f)
318 AI_DEVICE constexpr AtRGBA operator-(
const AtRGBA& rgba)
const
320 return AtRGBA(r - rgba.r,
326 AI_DEVICE AtRGBA& operator-=(
const AtRGBA& rgba)
335 AI_DEVICE constexpr AtRGBA operator-(
float f)
const
343 AI_DEVICE AtRGBA& operator-=(
float f)
352 AI_DEVICE constexpr AtRGBA operator-()
const
354 return AtRGBA(-r, -g, -b, -a);
357 AI_DEVICE constexpr AtRGBA operator*(
const AtRGBA& rgba)
const
359 return AtRGBA(r * rgba.r,
365 AI_DEVICE AtRGBA operator*=(
const AtRGBA& rgba)
374 AI_DEVICE constexpr AtRGBA operator*(
float f)
const
382 AI_DEVICE AtRGBA operator*=(
float f)
391 AI_DEVICE constexpr AtRGBA operator/(
const AtRGBA& rgba)
const
393 return AtRGBA(r / rgba.r,
399 AI_DEVICE AtRGBA operator/=(
const AtRGBA& rgba)
408 AI_DEVICE AtRGBA operator/(
float f)
const
416 AI_DEVICE AtRGBA operator/=(
float f)
425 AI_DEVICE constexpr
bool operator==(
const AtRGBA& rgba)
const
427 return (r == rgba.r && g == rgba.g && b == rgba.b && a == rgba.a);
430 AI_DEVICE constexpr
bool operator!=(
const AtRGBA& rgba)
const
432 return !(*
this == rgba);
435 AI_DEVICE AtRGBA& operator=(
float f)
444 AI_DEVICE
float& operator[](
unsigned int i)
449 AI_DEVICE constexpr
const float& operator[](
unsigned int i)
const
454 AI_DEVICE
friend constexpr AtRGBA operator*(
float f,
const AtRGBA& rgba);
455 AI_DEVICE
friend constexpr AtRGBA operator+(
float f,
const AtRGBA& rgba);
456 AI_DEVICE
friend constexpr AtRGBA operator-(
float f,
const AtRGBA& rgba);
459 AI_DEVICE
inline constexpr
AtRGBA operator*(
float f,
const AtRGBA& rgba)
464 AI_DEVICE
inline constexpr
AtRGBA operator+(
float f,
const AtRGBA& rgba)
469 AI_DEVICE
inline constexpr
AtRGBA operator-(
float f,
const AtRGBA& rgba)
517 AI_DEVICE
inline constexpr AtRGB::AtRGB(
const AtRGBA& rgba) : r(rgba.r), g(rgba.g), b(rgba.b) { }
550 c.r =
AiMax(c.r, 0.0f);
551 c.g =
AiMax(c.g, 0.0f);
552 c.b =
AiMax(c.b, 0.0f);
560 return std::abs(c.r) < epsilon && std::abs(c.g) < epsilon && std::abs(c.b) < epsilon;
568 return AtRGB(std::abs(c.r),
578 return AtRGBA(std::abs(c.r),
589 return AiMax(c.r, c.g, c.b);
597 return AiMax(c.r, c.g, c.b);
605 return std::abs(c1.r - c2.r) >= t || std::abs(c1.g - c2.g) >= t || std::abs(c1.b - c2.b) >= t;
613 return (c.r + c.g + c.b) / 3;
621 return (rgba.r + rgba.g + rgba.b) / 3;
640 return c*c0 + a*c1 + b*c2;
643 AI_API AI_DEVICE AI_PURE
AtRGB AiColorHeatMap(
const AtRGB* map_colors,
const float* map_values,
unsigned int map_length,
float lookup);
650 #ifdef AI_CPU_COMPILER
651 static constexpr
const AtRGB AI_RGB_BLACK (0.0f, 0.0f, 0.0f);
652 static constexpr
const AtRGB AI_RGB_ZERO (0.0f, 0.0f, 0.0f);
653 static constexpr
const AtRGB AI_RGB_RED (1.0f, 0.0f, 0.0f);
654 static constexpr
const AtRGB AI_RGB_GREEN (0.0f, 1.0f, 0.0f);
655 static constexpr
const AtRGB AI_RGB_BLUE (0.0f, 0.0f, 1.0f);
656 static constexpr
const AtRGB AI_RGB_50GREY(0.5f, 0.5f, 0.5f);
657 static constexpr
const AtRGB AI_RGB_WHITE (1.0f, 1.0f, 1.0f);
659 __device__
static const AtRGB AI_RGB_BLACK (0.0f, 0.0f, 0.0f);
660 __device__
static const AtRGB AI_RGB_ZERO (0.0f, 0.0f, 0.0f);
661 __device__
static const AtRGB AI_RGB_RED (1.0f, 0.0f, 0.0f);
662 __device__
static const AtRGB AI_RGB_GREEN (0.0f, 1.0f, 0.0f);
663 __device__
static const AtRGB AI_RGB_BLUE (0.0f, 0.0f, 1.0f);
664 __device__
static const AtRGB AI_RGB_50GREY(0.5f, 0.5f, 0.5f);
665 __device__
static const AtRGB AI_RGB_WHITE (1.0f, 1.0f, 1.0f);
668 #ifdef AI_CPU_COMPILER
669 static constexpr
const AtRGBA AI_RGBA_ZERO (0.0f, 0.0f, 0.0f, 0.0f);
670 static constexpr
const AtRGBA AI_RGBA_RED (1.0f, 0.0f, 0.0f, 1.0f);
671 static constexpr
const AtRGBA AI_RGBA_GREEN (0.0f, 1.0f, 0.0f, 1.0f);
672 static constexpr
const AtRGBA AI_RGBA_BLUE (0.0f, 0.0f, 1.0f, 1.0f);
673 static constexpr
const AtRGBA AI_RGBA_50GREY(0.5f, 0.5f, 0.5f, 1.0f);
674 static constexpr
const AtRGBA AI_RGBA_WHITE (1.0f, 1.0f, 1.0f, 1.0f);
676 __device__
static const AtRGBA AI_RGBA_ZERO (0.0f, 0.0f, 0.0f, 0.0f);
677 __device__
static const AtRGBA AI_RGBA_RED (1.0f, 0.0f, 0.0f, 1.0f);
678 __device__
static const AtRGBA AI_RGBA_GREEN (0.0f, 1.0f, 0.0f, 1.0f);
679 __device__
static const AtRGBA AI_RGBA_BLUE (0.0f, 0.0f, 1.0f, 1.0f);
680 __device__
static const AtRGBA AI_RGBA_50GREY(0.5f, 0.5f, 0.5f, 1.0f);
681 __device__
static const AtRGBA AI_RGBA_WHITE (1.0f, 1.0f, 1.0f, 1.0f);
RGB color.
Definition: ai_color.h:31
Definition: ai_comparison.h:16
AI_API AI_PURE bool AiRGBIsFinite(const AtRGB &rgba)
Check to see if an RGB color has any corrupted components (nan or infinite).
Definition: ai_color.cpp:53
AI_DEVICE constexpr T AiMax(T a, T b)
Maximum of 'a' and 'b'.
Definition: ai_math.h:43
AI_API AI_PURE bool AiRGBAIsFinite(const AtRGBA &rgba)
Check to see if an RGBA color has any corrupted components (nan or infinite).
Definition: ai_color.cpp:61
DLL export prefix for API functions (necessary for multi-platform development)
AI_DEVICE constexpr AtRGBA AiRGBAClamp(const AtRGBA &c, float lo, float hi)
Clamp the RGBA color vector to the specified range.
Definition: ai_color.h:537
AI_API AI_DEVICE AI_PURE AtRGB AiColorHeatMap(const AtRGB *map_colors, const float *map_values, unsigned int map_length, float lookup)
Interpolate a value according to a heat map (piecewise linear color map).
Definition: ai_color.cpp:18
AI_DEVICE constexpr T AiClamp(T v, T lo, T hi)
Clamp the input to the specified range.
Definition: ai_math.h:101
AtRGB AiBerpRGB(float a, float b, const AtRGB &c0, const AtRGB &c1, const AtRGB &c2)
Barycentric interpolation of triangle vertex colors.
Definition: ai_color.h:637
bool AiColorThreshold(const AtRGB &c1, const AtRGB &c2, float t)
Check to see if two colors differ by more than a threhsold.
Definition: ai_color.h:603
#define AI_EPSILON
System epsilon value.
Definition: ai_constants.h:41
AI_DEVICE constexpr AtRGB AiRGBClamp(const AtRGB &c, float lo, float hi)
Clamp the RGB color vector to the specified range.
Definition: ai_color.h:527
RGB color + alpha.
Definition: ai_color.h:266
Various useful constants.
AI_DEVICE constexpr float AiColorMaxRGB(const AtRGB &c)
Max RGB component of color.
Definition: ai_color.h:587
AI_DEVICE AtRGB AiColorABS(const AtRGB &c)
Absolute value of color.
Definition: ai_color.h:566
AI_DEVICE void AiColorClipToZero(AtRGB &c)
Clip negative values.
Definition: ai_color.h:548
AI_DEVICE constexpr float AiColorToGrey(const AtRGB &c)
Convert a RGB color to grey scale (take average of R, G, B)
Definition: ai_color.h:611
AtString class for fast comparisons.
AI_DEVICE bool AiColorIsSmall(const AtRGB &c, float epsilon=AI_EPSILON)
Check for almost black.
Definition: ai_color.h:558