From 6efd88b82f8cdbba116bd91e7e32f7793bdf5f62 Mon Sep 17 00:00:00 2001 From: Yuxuan Shui Date: Sun, 10 Nov 2019 03:37:11 +0000 Subject: [PATCH] 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 --- src/backend/gl/gl_common.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/backend/gl/gl_common.c b/src/backend/gl/gl_common.c index 3069986..ec19d03 100644 --- a/src/backend/gl/gl_common.c +++ b/src/backend/gl/gl_common.c @@ -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);