Skip to content

Commit

Permalink
gl_common: use Rec. 709 for luminance calculation
Browse files Browse the repository at this point in the history
This is however monitor dependent. But Rec. 709 is probably close to
what most people uses.

Signed-off-by: Yuxuan Shui <[email protected]>
  • Loading branch information
yshui committed Nov 10, 2019
1 parent 7dd843f commit 6efd88b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/backend/gl/gl_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 6efd88b

Please sign in to comment.