mirror of
https://github.com/mpv-player/mpv
synced 2025-03-11 08:37:59 +00:00
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 ed8fad729d
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.
This commit is contained in:
parent
a400c8ff84
commit
a558117909
@ -671,7 +671,10 @@ static void compile_shaders(struct gl_priv *p)
|
||||
shader_prelude);
|
||||
|
||||
char *header_osd = talloc_strdup(tmp, header);
|
||||
shader_def_opt(&header_osd, "USE_3DLUT", p->use_lut_3d);
|
||||
shader_def_opt(&header_osd, "USE_OSD_LINEAR_CONV", p->use_srgb &&
|
||||
!p->use_lut_3d);
|
||||
shader_def_opt(&header_osd, "USE_OSD_3DLUT", p->use_lut_3d);
|
||||
shader_def_opt(&header_osd, "USE_OSD_SRGB", p->use_srgb);
|
||||
|
||||
for (int n = 0; n < SUBBITMAP_COUNT; n++) {
|
||||
const char *name = osd_shaders[n];
|
||||
|
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user