summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNiklas Haas <git@nand.wakku.to>2015-02-03 08:31:06 +0100
committerNiklas Haas <git@nand.wakku.to>2015-02-03 08:47:48 +0100
commitfa1698cb9afb1ef6e602372804dd3999f0b242a0 (patch)
treececaa6c19e1378946356622385fdcab57033bdbd
parent5de7f1c5acc64e2d15b763bb12fe25345bd46801 (diff)
downloadmpv-fa1698cb9afb1ef6e602372804dd3999f0b242a0.tar.bz2
mpv-fa1698cb9afb1ef6e602372804dd3999f0b242a0.tar.xz
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).
-rw-r--r--video/out/gl_video_shaders.glsl9
1 files changed, 4 insertions, 5 deletions
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