15 #include <vsg/maths/vec4.h>
20 constexpr T color_cast(
float r,
float g,
float b,
float a)
26 constexpr
float color_cast<float>(
float r,
float,
float,
float)
32 constexpr vec2 color_cast<vec2>(
float r,
float g,
float,
float)
38 constexpr vec3 color_cast<vec3>(
float r,
float g,
float b,
float)
44 constexpr vec4 color_cast<vec4>(
float r,
float g,
float b,
float a)
50 constexpr ubvec4 color_cast<ubvec4>(
float r,
float g,
float b,
float a)
52 return {
static_cast<uint8_t
>(r * 255.0f),
static_cast<uint8_t
>(g * 255.0f),
static_cast<uint8_t
>(b * 255.0f),
static_cast<uint8_t
>(a * 255.0f)};
56 constexpr T transparent_black()
58 return color_cast<T>(0.0f, 0.0f, 0.0f, 0.0f);
62 constexpr T opaque_black()
64 return color_cast<T>(0.0f, 0.0f, 0.0f, 1.0f);
68 constexpr T transparent_white()
70 return color_cast<T>(1.0f, 1.0f, 1.0f, 0.0f);
74 constexpr T opaque_white()
76 return color_cast<T>(0.0f, 0.0f, 1.0f, 1.0f);
80 constexpr T color_cast(VkBorderColor borderColor)
84 case (VK_BORDER_COLOR_FLOAT_TRANSPARENT_BLACK):
85 case (VK_BORDER_COLOR_INT_TRANSPARENT_BLACK):
86 return transparent_black<T>();
87 case (VK_BORDER_COLOR_FLOAT_OPAQUE_BLACK):
88 case (VK_BORDER_COLOR_INT_OPAQUE_BLACK):
89 return opaque_black<T>();
90 case (VK_BORDER_COLOR_FLOAT_OPAQUE_WHITE):
91 case (VK_BORDER_COLOR_INT_OPAQUE_WHITE):
92 return opaque_white<T>();
95 return transparent_black<T>();
100 constexpr t_vec4<T> linear_to_sRGB(
const t_vec4<T>& src)
102 const T exponent = 2.2;
103 return t_vec4<T>(std::pow(src.r, exponent), std::pow(src.g, exponent), std::pow(src.b, exponent), src.a);
107 constexpr t_vec4<T> linear_to_sRGB(T r, T g, T b, T a)
109 const T exponent = 2.2;
110 return t_vec4<T>(std::pow(r, exponent), std::pow(g, exponent), std::pow(b, exponent), a);
114 constexpr t_vec4<T> sRGB_to_linear(
const t_vec4<T>& src)
116 const T exponent = 1.0 / 2.2;
117 return t_vec4<T>(std::pow(src.r, exponent), std::pow(src.g, exponent), std::pow(src.b, exponent), src.a);
121 constexpr t_vec4<T> sRGB_to_linear(T r, T g, T b, T a)
123 const T exponent = 1.0 / 2.2;
124 return t_vec4<T>(std::pow(r, exponent), std::pow(g, exponent), std::pow(b, exponent), a);