gl_common: use Rec. 709 for luminance calculation

This is however monitor dependent. But Rec. 709 is probably close to
what most people uses.

Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
Yuxuan Shui 2019-11-10 03:37:11 +00:00
parent 7dd843fe4f
commit 6efd88b82f
No known key found for this signature in database
GPG Key ID: 37C999F617EA1A47
1 changed files with 4 additions and 1 deletions

View File

@ -1163,7 +1163,10 @@ const char *win_shader_glsl = GLSL(330,
c = vec4(c.rgb * (1.0 - dim), c.a) * opacity;
vec3 rgb_brightness = texelFetch(brightness, ivec2(0, 0), 0).rgb;
float brightness = (rgb_brightness[0] + rgb_brightness[1] + rgb_brightness[2]) / 3;
// Ref: https://en.wikipedia.org/wiki/Relative_luminance
float brightness = rgb_brightness.r * 0.21 +
rgb_brightness.g * 0.72 +
rgb_brightness.b * 0.07;
if (brightness > max_brightness)
c.rgb = c.rgb * (max_brightness / brightness);