From dedd5d63fb874e0137d27e487d746f27f4576ef7 Mon Sep 17 00:00:00 2001 From: Antonio Scandurra Date: Wed, 26 Jan 2022 17:06:20 +0100 Subject: [PATCH] Fix blending of quad's border with background Co-Authored-By: Nathan Sobo --- .../gpui/src/platform/mac/shaders/shaders.metal | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/crates/gpui/src/platform/mac/shaders/shaders.metal b/crates/gpui/src/platform/mac/shaders/shaders.metal index b484739edb..385c8d25d8 100644 --- a/crates/gpui/src/platform/mac/shaders/shaders.metal +++ b/crates/gpui/src/platform/mac/shaders/shaders.metal @@ -66,21 +66,13 @@ float4 quad_sdf(QuadFragmentInput input) { border_width = vertical_border; } - float4 color; - if (border_width == 0.) { - color = input.background_color; - } else { - float4 border_color = float4(mix(float3(input.background_color), float3(input.border_color), input.border_color.a), 1.); + float4 color = input.background_color * float4(1., 1., 1., saturate(0.5 - distance)); + if (border_width != 0.) { float inset_distance = distance + border_width; - color = mix( - border_color, - input.background_color, - saturate(0.5 - inset_distance) - ); + color = mix(input.border_color, color, saturate(0.5 - inset_distance)); } - float4 coverage = float4(1., 1., 1., saturate(0.5 - distance)); - return coverage * color; + return color; } vertex QuadFragmentInput quad_vertex(