This commit is contained in:
Kovid Goyal 2023-04-30 08:28:02 +05:30
parent 8020d5823b
commit 07dbfaa297
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C

View File

@ -22,6 +22,14 @@ const uvec2 pos_map[] = uvec2[4](
uvec2(LEFT, TOP) uvec2(LEFT, TOP)
); );
float linear2srgb(float x) {
// Linear to sRGB conversion. Needed to match alpha from the cell shader
float lower = 12.92 * x;
float upper = 1.055 * pow(x, 1.0f / 2.4f) - 0.055f;
return mix(lower, upper, step(0.0031308f, x));
}
float to_color(uint c) { float to_color(uint c) {
return gamma_lut[c & FF]; return gamma_lut[c & FF];
} }
@ -45,5 +53,5 @@ void main() {
color3 = is_window_bg * window_bg + (1. - is_window_bg) * color3; color3 = is_window_bg * window_bg + (1. - is_window_bg) * color3;
float final_opacity = is_default_bg * tint_opacity + (1. - is_default_bg) * background_opacity; float final_opacity = is_default_bg * tint_opacity + (1. - is_default_bg) * background_opacity;
float final_premult_opacity = is_default_bg * tint_premult + (1. - is_default_bg) * background_opacity; float final_premult_opacity = is_default_bg * tint_premult + (1. - is_default_bg) * background_opacity;
color = vec4(color3 * final_premult_opacity, final_opacity); color = vec4(color3 * final_premult_opacity, linear2srgb(final_opacity));
} }