wlroots/render/vulkan/shaders
John Lindgren 2ec08b38d8 [RFC] vulkan: compensate alpha to better match perceptual blend intent
The Vulkan renderer performs alpha blending in linear RGB space, which
preserves hue better than blending sRGB-encoded values directly (as the
gles and pixman renderers do), but unfortunately tends to give a
too-bright result when blending dark and light colors.

(In desktop usage, this especially affects dark, semi-transparent
tooltips, which appear significantly more transparent than expected,
affecting readability if light text underneath shows through.)

This is a novel (I think) approach to compensating for this effect by
adjusting the alpha value of the source texture - basically the result
is that dark semi-transparent pixels are made a little more opaque,
while light semi-transparent pixels are made a little more transparent.
Alpha values of 0 and 1 are unchanged.

I am somewhat new to science of color blending (Björn Ottosson's page,
"How software gets color wrong" is very enlightening) but I think this
approach makes at least a little bit of sense theoretically, and the
result seems to me subjectively to be an improvement.

Analysis from an expert on the subject would be greatly appreciated.

v2: compensate alpha in solid color conversions also
v3: un-premultiply average value for solid color conversion
2024-12-14 11:55:03 -05:00
..
common.vert render/vulkan: Optimize vertex shader 2021-11-23 15:46:24 +00:00
meson.build render/vulkan: allow rendering to non-8-bit buffers 2023-05-12 15:09:02 +00:00
output.frag render/vulkan: add lut3d output shader option 2024-04-26 17:17:36 +00:00
quad.frag render/vulkan: add Vulkan renderer 2021-10-18 11:51:13 +02:00
texture.frag [RFC] vulkan: compensate alpha to better match perceptual blend intent 2024-12-14 11:55:03 -05:00