diff options
author | nand <nand@lavabit.com> | 2012-11-10 19:08:21 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-11 17:56:42 +0100 |
commit | ed8fad729d0481ebbedd020694c3624672c38425 (patch) | |
tree | 2fecf6cb5486a1ebc1f95eb55274f279d9a996ba /libvo/vo_opengl_shaders.glsl | |
parent | c78243c03e25aa62171e7353ed455d1ac6ea77b0 (diff) | |
download | mpv-ed8fad729d0481ebbedd020694c3624672c38425.tar.bz2 mpv-ed8fad729d0481ebbedd020694c3624672c38425.tar.xz |
vo_opengl: add manual sRGB companding to not artifact when dithering
Patch by nand. Modified not to use macros in the GLSL, and also remove
the checks for framebuffer presence. (Disabling ICC if no sRGB
framebuffer is available was probably a bug.)
Diffstat (limited to 'libvo/vo_opengl_shaders.glsl')
-rw-r--r-- | libvo/vo_opengl_shaders.glsl | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/libvo/vo_opengl_shaders.glsl b/libvo/vo_opengl_shaders.glsl index 01e1433f7f..32804b99ff 100644 --- a/libvo/vo_opengl_shaders.glsl +++ b/libvo/vo_opengl_shaders.glsl @@ -292,6 +292,12 @@ vec4 sample_sharpen5(sampler2D tex, vec2 texsize, vec2 texcoord) { return p + t * filter_param1; } +vec3 srgb_compand(vec3 v) +{ + return mix(1.055 * pow(v, vec3(1.0/2.4)) - vec3(0.055), v * 12.92, + lessThanEqual(v, vec3(0.0031308))); +} + void main() { #ifdef USE_PLANAR vec3 color = vec3(SAMPLE_L(textures[0], textures_size[0], texcoord).r, @@ -325,6 +331,9 @@ void main() { #ifdef USE_3DLUT color = texture3D(lut_3d, color).rgb; #endif +#ifdef USE_SRGB + color.rgb = srgb_compand(color.rgb); +#endif #ifdef USE_DITHER float dither_value = texture(dither, gl_FragCoord.xy / dither_size).r; color = floor(color * dither_multiply + dither_value ) / dither_quantization; |