From fa1698cb9afb1ef6e602372804dd3999f0b242a0 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Tue, 3 Feb 2015 08:31:06 +0100 Subject: vo_opengl: always clamp the video to range 0-1 Before this, enabling :gamma in combination with :sigmoid and probably a few other things results in ugly artifacts because the video isn't clamped until after the :gamma was applied (or at all, if the cms_matrix is unused). --- video/out/gl_video_shaders.glsl | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'video') diff --git a/video/out/gl_video_shaders.glsl b/video/out/gl_video_shaders.glsl index 3bc72ddea7..b13d518e6c 100644 --- a/video/out/gl_video_shaders.glsl +++ b/video/out/gl_video_shaders.glsl @@ -482,21 +482,20 @@ void main() { // Inverse of USE_SIGMOID color = (1.0/(1.0 + exp(sig_slope * (sig_center - color))) - sig_offset) / sig_scale; #endif -#ifdef USE_GAMMA_POW - // User-defined gamma correction factor (via the gamma sub-option) - color = pow(color, inv_gamma); -#endif #ifdef USE_CMS_MATRIX // Convert to the right target gamut first (to BT.709 for sRGB, // and to BT.2020 for 3DLUT). color = cms_matrix * color; - +#endif // Clamp to the target gamut. This clamp is needed because the gamma // functions are not well-defined outside this range, which is related to // the fact that they're not representable on the target device. // TODO: Desaturate colorimetrically; this happens automatically for // 3dlut targets but not for sRGB mode. Not sure if this is a requirement. color = clamp(color, 0.0, 1.0); +#ifdef USE_GAMMA_POW + // User-defined gamma correction factor (via the gamma sub-option) + color = pow(color, inv_gamma); #endif #ifdef USE_3DLUT // For the 3DLUT we are arbitrarily using 2.4 as input gamma to reduce -- cgit v1.2.3