From e62817b8252974b8a98393275874ee303840bf13 Mon Sep 17 00:00:00 2001 From: LaG1924 <12997935+LaG1924@users.noreply.github.com> Date: Fri, 12 May 2017 18:49:50 +0500 Subject: 2017-05-12 --- depedencies/include/glm/gtc/color_space.inl | 75 +++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 depedencies/include/glm/gtc/color_space.inl (limited to 'depedencies/include/glm/gtc/color_space.inl') 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 class vecType> + struct compute_rgbToSrgb + { + GLM_FUNC_QUALIFIER static vecType call(vecType const& ColorRGB, T GammaCorrection) + { + vecType const ClampedColor(clamp(ColorRGB, static_cast(0), static_cast(1))); + + return mix( + pow(ClampedColor, vecType(GammaCorrection)) * static_cast(1.055) - static_cast(0.055), + ClampedColor * static_cast(12.92), + lessThan(ClampedColor, vecType(static_cast(0.0031308)))); + } + }; + + template + struct compute_rgbToSrgb + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorRGB, T GammaCorrection) + { + return tvec4(compute_rgbToSrgb::call(tvec3(ColorRGB), GammaCorrection), ColorRGB.w); + } + }; + + template class vecType> + struct compute_srgbToRgb + { + GLM_FUNC_QUALIFIER static vecType call(vecType const& ColorSRGB, T Gamma) + { + return mix( + pow((ColorSRGB + static_cast(0.055)) * static_cast(0.94786729857819905213270142180095), vecType(Gamma)), + ColorSRGB * static_cast(0.07739938080495356037151702786378), + lessThanEqual(ColorSRGB, vecType(static_cast(0.04045)))); + } + }; + + template + struct compute_srgbToRgb + { + GLM_FUNC_QUALIFIER static tvec4 call(tvec4 const& ColorSRGB, T Gamma) + { + return tvec4(compute_srgbToRgb::call(tvec3(ColorSRGB), Gamma), ColorSRGB.w); + } + }; +}//namespace detail + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const& ColorLinear) + { + return detail::compute_rgbToSrgb::call(ColorLinear, static_cast(0.41666)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertLinearToSRGB(vecType const& ColorLinear, T Gamma) + { + return detail::compute_rgbToSrgb::call(ColorLinear, static_cast(1) / Gamma); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const& ColorSRGB) + { + return detail::compute_srgbToRgb::call(ColorSRGB, static_cast(2.4)); + } + + template class vecType> + GLM_FUNC_QUALIFIER vecType convertSRGBToLinear(vecType const& ColorSRGB, T Gamma) + { + return detail::compute_srgbToRgb::call(ColorSRGB, Gamma); + } +}//namespace glm -- cgit v1.2.3