aboutsummaryrefslogtreecommitdiff
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
parent7e1202b011f68295302607460950f2eb5c20f4e6 (diff)
parent1a3296d65a5d45090651548a2ec48ef47eaea8ee (diff)
Merge pull request #18805 from mglae/matrix_tonemap_fix
OpenGL tone map: fix black screen using ACES and Hable
-rw-r--r--system/shaders/GL/4.0/gl_yuv2rgb_filter4.glsl19
-rw-r--r--xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp3
2 files changed, 19 insertions, 3 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
diff --git a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp
index 7ef9e8ef10..e437dddf93 100644
--- a/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp
+++ b/xbmc/cores/VideoPlayer/VideoRenderers/VideoShaders/YUV2RGBShaderGL.cpp
@@ -272,7 +272,8 @@ float BaseYUV2RGBGLSLShader::GetLuminanceValue() const //Maybe move this to linu
lum3 = static_cast<float>(m_lightMetadata.MaxFALL);
lum1 = (lum1 * 0.5f) + (lum2 * 0.2f) + (lum3 * 0.3f);
}
- else if (m_hasDisplayMetadata && m_displayMetadata.has_luminance)
+ else if (m_hasDisplayMetadata && m_displayMetadata.has_luminance &&
+ m_displayMetadata.max_luminance.num)
{
uint16_t lum = m_displayMetadata.max_luminance.num / m_displayMetadata.max_luminance.den;
lum1 = static_cast<float>(lum);