aboutsummaryrefslogtreecommitdiff
path: root/system
diff options
context:
space:
mode:
authorfuzzard <fuzzard@users.noreply.github.com>2020-11-26 13:20:14 +1000
committerGitHub <noreply@github.com>2020-11-26 13:20:14 +1000
commitc4f9d23990e4b7d9eceb35d34ed259aa847d9a65 (patch)
treec83a9cfe03db9a1bccb8feaa0ab3bb3f15e4d798 /system
parent7e1202b011f68295302607460950f2eb5c20f4e6 (diff)
parent1a3296d65a5d45090651548a2ec48ef47eaea8ee (diff)
Merge pull request #18805 from mglae/matrix_tonemap_fix
OpenGL tone map: fix black screen using ACES and Hable
Diffstat (limited to 'system')
-rw-r--r--system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl19
1 files changed, 17 insertions, 2 deletions
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