summaryrefslogtreecommitdiffstats
path: root/depedencies/include/glm/gtc/color_space.inl
diff options
context:
space:
mode:
authorLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
committerLaG1924 <12997935+LaG1924@users.noreply.github.com>2017-05-12 15:49:50 +0200
commite62817b8252974b8a98393275874ee303840bf13 (patch)
tree4565935f06e369f4a84410b0c098958e07a750c7 /depedencies/include/glm/gtc/color_space.inl
parent2017-05-10 (diff)
downloadAltCraft-e62817b8252974b8a98393275874ee303840bf13.tar
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.gz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.bz2
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.lz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.xz
AltCraft-e62817b8252974b8a98393275874ee303840bf13.tar.zst
AltCraft-e62817b8252974b8a98393275874ee303840bf13.zip
Diffstat (limited to 'depedencies/include/glm/gtc/color_space.inl')
-rw-r--r--depedencies/include/glm/gtc/color_space.inl75
1 files changed, 75 insertions, 0 deletions
diff --git a/depedencies/include/glm/gtc/color_space.inl b/depedencies/include/glm/gtc/color_space.inl
new file mode 100644
index 0000000..c9a44ef
--- /dev/null
+++ b/depedencies/include/glm/gtc/color_space.inl
@@ -0,0 +1,75 @@
+/// @ref gtc_color_space
+/// @file glm/gtc/color_space.inl
+
+namespace glm{
+namespace detail
+{
+ template <typename T, precision P, template <typename, precision> class vecType>
+ struct compute_rgbToSrgb
+ {
+ GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const& ColorRGB, T GammaCorrection)
+ {
+ vecType<T, P> const ClampedColor(clamp(ColorRGB, static_cast<T>(0), static_cast<T>(1)));
+
+ return mix(
+ pow(ClampedColor, vecType<T, P>(GammaCorrection)) * static_cast<T>(1.055) - static_cast<T>(0.055),
+ ClampedColor * static_cast<T>(12.92),
+ lessThan(ClampedColor, vecType<T, P>(static_cast<T>(0.0031308))));
+ }
+ };
+
+ template <typename T, precision P>
+ struct compute_rgbToSrgb<T, P, tvec4>
+ {
+ GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const& ColorRGB, T GammaCorrection)
+ {
+ return tvec4<T, P>(compute_rgbToSrgb<T, P, tvec3>::call(tvec3<T, P>(ColorRGB), GammaCorrection), ColorRGB.w);
+ }
+ };
+
+ template <typename T, precision P, template <typename, precision> class vecType>
+ struct compute_srgbToRgb
+ {
+ GLM_FUNC_QUALIFIER static vecType<T, P> call(vecType<T, P> const& ColorSRGB, T Gamma)
+ {
+ return mix(
+ pow((ColorSRGB + static_cast<T>(0.055)) * static_cast<T>(0.94786729857819905213270142180095), vecType<T, P>(Gamma)),
+ ColorSRGB * static_cast<T>(0.07739938080495356037151702786378),
+ lessThanEqual(ColorSRGB, vecType<T, P>(static_cast<T>(0.04045))));
+ }
+ };
+
+ template <typename T, precision P>
+ struct compute_srgbToRgb<T, P, tvec4>
+ {
+ GLM_FUNC_QUALIFIER static tvec4<T, P> call(tvec4<T, P> const& ColorSRGB, T Gamma)
+ {
+ return tvec4<T, P>(compute_srgbToRgb<T, P, tvec3>::call(tvec3<T, P>(ColorSRGB), Gamma), ColorSRGB.w);
+ }
+ };
+}//namespace detail
+
+ template <typename T, precision P, template <typename, precision> class vecType>
+ GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const& ColorLinear)
+ {
+ return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(0.41666));
+ }
+
+ template <typename T, precision P, template <typename, precision> class vecType>
+ GLM_FUNC_QUALIFIER vecType<T, P> convertLinearToSRGB(vecType<T, P> const& ColorLinear, T Gamma)
+ {
+ return detail::compute_rgbToSrgb<T, P, vecType>::call(ColorLinear, static_cast<T>(1) / Gamma);
+ }
+
+ template <typename T, precision P, template <typename, precision> class vecType>
+ GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const& ColorSRGB)
+ {
+ return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, static_cast<T>(2.4));
+ }
+
+ template <typename T, precision P, template <typename, precision> class vecType>
+ GLM_FUNC_QUALIFIER vecType<T, P> convertSRGBToLinear(vecType<T, P> const& ColorSRGB, T Gamma)
+ {
+ return detail::compute_srgbToRgb<T, P, vecType>::call(ColorSRGB, Gamma);
+ }
+}//namespace glm