mirror of
https://gitlab.freedesktop.org/wlroots/wlroots.git
synced 2026-04-19 06:47:02 -04:00
Merge branch 'vulkan-alpha-blend' into 'master'
[RFC] vulkan: compensate alpha to better match perceptual blend intent See merge request wlroots/wlroots!4634
This commit is contained in:
commit
f4cfc79a6d
3 changed files with 81 additions and 8 deletions
|
|
@ -26,11 +26,17 @@ vec4 srgb_color_to_linear(vec4 color) {
|
|||
return vec4(0);
|
||||
}
|
||||
color.rgb /= color.a;
|
||||
// Estimate perceptual lightness from sRGB values
|
||||
float v = (color.r + color.g + color.b) / 3;
|
||||
color.rgb = vec3(
|
||||
srgb_channel_to_linear(color.r),
|
||||
srgb_channel_to_linear(color.g),
|
||||
srgb_channel_to_linear(color.b)
|
||||
);
|
||||
// Adjust alpha to make dark semi-transparent overlays a bit more
|
||||
// opaque, better matching perceptual intent compared to simple
|
||||
// linear blending (see README-alpha-blend for a longer discussion)
|
||||
color.a = ((v - 0.5) * color.a * color.a + color.a) / (v + 0.5);
|
||||
color.rgb *= color.a;
|
||||
return color;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue