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,
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,
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,
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,
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);
198AI_DEVICE
inline constexpr AtRGB operator*(
float f,
const AtRGB& rgb)
203AI_DEVICE
inline constexpr AtRGB operator+(
float f,
const AtRGB& rgb)
208AI_DEVICE
inline constexpr AtRGB operator-(
float f,
const AtRGB& rgb)
210 return AtRGB(f - rgb.r,
215AI_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
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
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
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
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);
459AI_DEVICE
inline constexpr AtRGBA operator*(
float f,
const AtRGBA& rgba)
464AI_DEVICE
inline constexpr AtRGBA operator+(
float f,
const AtRGBA& rgba)
469AI_DEVICE
inline constexpr AtRGBA operator-(
float f,
const AtRGBA& rgba)
517AI_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;
643AI_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
651static constexpr const AtRGB AI_RGB_BLACK (0.0f, 0.0f, 0.0f);
652static constexpr const AtRGB AI_RGB_ZERO (0.0f, 0.0f, 0.0f);
653static constexpr const AtRGB AI_RGB_RED (1.0f, 0.0f, 0.0f);
654static constexpr const AtRGB AI_RGB_GREEN (0.0f, 1.0f, 0.0f);
655static constexpr const AtRGB AI_RGB_BLUE (0.0f, 0.0f, 1.0f);
656static constexpr const AtRGB AI_RGB_50GREY(0.5f, 0.5f, 0.5f);
657static 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
669static constexpr const AtRGBA AI_RGBA_ZERO (0.0f, 0.0f, 0.0f, 0.0f);
670static constexpr const AtRGBA AI_RGBA_RED (1.0f, 0.0f, 0.0f, 1.0f);
671static constexpr const AtRGBA AI_RGBA_GREEN (0.0f, 1.0f, 0.0f, 1.0f);
672static constexpr const AtRGBA AI_RGBA_BLUE (0.0f, 0.0f, 1.0f, 1.0f);
673static constexpr const AtRGBA AI_RGBA_50GREY(0.5f, 0.5f, 0.5f, 1.0f);
674static 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);
DLL export prefix for API functions (necessary for multi-platform development)
Various useful constants.
AtString class for fast comparisons.
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_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:63
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
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
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
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
AI_DEVICE constexpr float AiColorMaxRGB(const AtRGB &c)
Max RGB component of color.
Definition: ai_color.h:587
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:55
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_DEVICE bool AiColorIsSmall(const AtRGB &c, float epsilon=AI_EPSILON)
Check for almost black.
Definition: ai_color.h:558
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:19
#define AI_EPSILON
System epsilon value
Definition: ai_constants.h:41
AI_DEVICE constexpr T AiClamp(T v, T lo, T hi)
Clamp the input to the specified range.
Definition: ai_math.h:101
AI_DEVICE constexpr T AiMax(T a, T b)
Maximum of 'a' and 'b'.
Definition: ai_math.h:43
Definition: ai_comparison.h:17
RGB color + alpha.
Definition: ai_color.h:267
RGB color.
Definition: ai_color.h:32