backend: gl: fix corner being drawn with wrong color
The outer pixels of the corner are drawn with antialiasing, but it color used for antialiasing is wrong. The estimated border color is used when there is actually no border. Related: #770 Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
@@ -1561,12 +1561,17 @@ const char *win_shader_glsl = GLSL(330,
|
||||
if (brightness > max_brightness)
|
||||
c.rgb = c.rgb * (max_brightness / brightness);
|
||||
|
||||
// Rim color is the color of the outer rim of the window, if there is no
|
||||
// border, it's the color of the window itself, otherwise it's the border.
|
||||
// Using mix() to avoid a branch here.
|
||||
vec4 rim_color = mix(c, border_color, clamp(border_width, 0.0f, 1.0f));
|
||||
|
||||
vec2 outer_size = vec2(textureSize(tex, 0));
|
||||
vec2 inner_size = outer_size - vec2(corner_radius) * 2.0f;
|
||||
float rect_distance = rectangle_sdf(texcoord - outer_size / 2.0f,
|
||||
inner_size / 2.0f) - corner_radius;
|
||||
if (rect_distance > 0.0f) {
|
||||
c = (1.0f - clamp(rect_distance, 0.0f, 1.0f)) * border_color;
|
||||
c = (1.0f - clamp(rect_distance, 0.0f, 1.0f)) * rim_color;
|
||||
} else {
|
||||
float factor = clamp(rect_distance + border_width, 0.0f, 1.0f);
|
||||
c = (1.0f - factor) * c + factor * border_color;
|
||||
|
||||
Reference in New Issue
Block a user