diff options
author | nand <nand@lavabit.com> | 2012-11-11 21:09:47 +0100 |
---|---|---|
committer | wm4 <wm4@nowhere> | 2012-11-11 21:34:58 +0100 |
commit | a55811790902b78915a1613f3551fe763ccda41a (patch) | |
tree | a06004b7f00899bd9b48285ea6846a6207c69efa /libvo/vo_opengl_shaders.glsl | |
parent | a400c8ff84a9d259923ee62f3ddc067d459d47eb (diff) | |
download | mpv-a55811790902b78915a1613f3551fe763ccda41a.tar.bz2 mpv-a55811790902b78915a1613f3551fe763ccda41a.tar.xz |
vo_opengl: fix srgb for subtitles
Based on a patch by nand. This is needed, because sRGB mode changes the
video over-all gamma. This has to be done for subtitles as well.
The final srgb_compand() call in the OSD shader compensates for the fact
that in ed8fad729d04 framebuffer use was replaced with doing sRGB
conversion manually by srgb_compand().
This only affects subtitles rendered with libass. Nothing is changed for
RGB subs.
Also change the USE_ flags for OSD shaders to USE_OSD_ to make the
difference between video and OSD rendering more apparent.
Diffstat (limited to 'libvo/vo_opengl_shaders.glsl')
-rw-r--r-- | libvo/vo_opengl_shaders.glsl | 24 |
1 files changed, 17 insertions, 7 deletions
diff --git a/libvo/vo_opengl_shaders.glsl b/libvo/vo_opengl_shaders.glsl index 32804b99ff..5dd67bbd52 100644 --- a/libvo/vo_opengl_shaders.glsl +++ b/libvo/vo_opengl_shaders.glsl @@ -37,6 +37,12 @@ # define in varying #endif +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))); +} + #!section vertex_all #if __VERSION__ < 130 @@ -61,9 +67,19 @@ void main() { #endif gl_Position = vec4(position, 1); color = vertex_color; -#ifdef USE_3DLUT + +#ifdef USE_OSD_LINEAR_CONV + // If no 3dlut is being used, we need to pull up to linear light for + // the sRGB function. *IF* 3dlut is used, we do not. + color.rgb = pow(color.rgb, vec3(2.2)); +#endif +#ifdef USE_OSD_3DLUT color = vec4(texture3D(lut_3d, color.rgb).rgb, color.a); #endif +#ifdef USE_OSD_SRGB + color.rgb = srgb_compand(color.rgb); +#endif + texcoord = vertex_texcoord; } @@ -292,12 +308,6 @@ 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, |