mirror of https://github.com/mpv-player/mpv
vo_opengl: make :srgb decompand the BT.709 values correctly
This is the same issue as addressed by257d9f1
, except this time for the :srgb option as well. (257d9f1
only addressed :icc-profile) The conditions of the srgb_compand mix() call are also flipped to prevent an off-by-one error.
This commit is contained in:
parent
391546c52f
commit
19caba0794
|
@ -45,8 +45,14 @@
|
||||||
#if __VERSION__ >= 130
|
#if __VERSION__ >= 130
|
||||||
vec3 srgb_compand(vec3 v)
|
vec3 srgb_compand(vec3 v)
|
||||||
{
|
{
|
||||||
return mix(1.055 * pow(v, vec3(1.0/2.4)) - vec3(0.055), v * 12.92,
|
return mix(v * 12.92, 1.055 * pow(v, vec3(1.0/2.4)) - vec3(0.055),
|
||||||
lessThanEqual(v, vec3(0.0031308)));
|
lessThanEqual(vec3(0.0031308), v));
|
||||||
|
}
|
||||||
|
|
||||||
|
vec3 bt709_expand(vec3 v)
|
||||||
|
{
|
||||||
|
return mix(v / 4.5, pow((v + vec3(0.099))/1.099, vec3(1/0.45)),
|
||||||
|
lessThanEqual(vec3(0.0812), v));
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -384,6 +390,13 @@ void main() {
|
||||||
color = texture3D(lut_3d, color).rgb;
|
color = texture3D(lut_3d, color).rgb;
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_SRGB
|
#ifdef USE_SRGB
|
||||||
|
// Go from "linear" (0.45) to BT.709 to true linear to sRGB
|
||||||
|
#ifndef USE_3DLUT
|
||||||
|
// Unless we are using a 3DLUT, in which case USE_LINEAR_CONV_INV
|
||||||
|
// already triggered earlier.
|
||||||
|
color = pow(color, vec3(0.45));
|
||||||
|
#endif
|
||||||
|
color = bt709_expand(color.rgb);
|
||||||
color.rgb = srgb_compand(color.rgb);
|
color.rgb = srgb_compand(color.rgb);
|
||||||
#endif
|
#endif
|
||||||
#ifdef USE_DITHER
|
#ifdef USE_DITHER
|
||||||
|
|
Loading…
Reference in New Issue