From 1a3296d65a5d45090651548a2ec48ef47eaea8ee Mon Sep 17 00:00:00 2001 From: mglae Date: Sat, 14 Nov 2020 19:58:41 +0100 Subject: gl_yuv2rgb_filter4.glsl: add ACES and Hable tone mapping --- system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'system') diff --git a/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl b/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl index 84e480c5ec..8a4658cd7b 100644 --- a/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl +++ b/system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl @@ -17,6 +17,7 @@ uniform mat3 m_primMat; uniform float m_gammaDstInv; uniform float m_gammaSrc; uniform float m_toneP1; +uniform float m_luminance; uniform vec3 m_coefsDst; in vec2 m_cordY; in vec2 m_cordU; @@ -115,9 +116,23 @@ vec4 process() rgb.rgb = max(vec3(0), m_primMat * rgb.rgb); rgb.rgb = pow(rgb.rgb, vec3(m_gammaDstInv)); -#if defined(XBMC_TONE_MAPPING) +#if defined(KODI_TONE_MAPPING_REINHARD) float luma = dot(rgb.rgb, m_coefsDst); - rgb.rgb *= tonemap(luma) / luma; + rgb.rgb *= reinhard(luma) / luma; + +#elif defined(KODI_TONE_MAPPING_ACES) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= (10000.0 / m_luminance) * (2.0 / m_toneP1); + rgb.rgb = aces(rgb.rgb); + rgb.rgb *= (1.24 / m_toneP1); + rgb.rgb = pow(rgb.rgb, vec3(0.27)); + +#elif defined(KODI_TONE_MAPPING_HABLE) + rgb.rgb = inversePQ(rgb.rgb); + rgb.rgb *= m_toneP1; + float wp = m_luminance / 100.0; + rgb.rgb = hable(rgb.rgb * wp) / hable(vec3(wp)); + rgb.rgb = pow(rgb.rgb, vec3(1.0 / 2.2)); #endif #endif -- cgit v1.2.3