Skip to content

Commit 901d71b

Browse files
authored
fix rounded borders on buttons (#13541)
# Objective - #13523 introduced a new bug on rounded corners in UI on buttons - there are artefacts outside of the border, and the text in buttons is more gray than it should be - example `color_grading`: <img width="1280" alt="Screenshot 2024-05-27 at 22 19 13" src="https://github.com/bevyengine/bevy/assets/8672791/fbb6a8ba-2096-4fcc-9c94-3764e9d16d2f"> ## Solution - Clamp alpha to be between 0.0 and 1.0 <img width="1280" alt="Screenshot 2024-05-27 at 22 18 19" src="https://github.com/bevyengine/bevy/assets/8672791/295d8e16-30eb-40cc-8d61-4995fca6dded">
1 parent 8684db1 commit 901d71b

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

crates/bevy_ui/src/render/ui.wgsl

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ fn draw(in: VertexOutput) -> vec4<f32> {
158158
let t = select(1.0 - step(0.0, border_distance), antialias(border_distance), external_distance < internal_distance);
159159

160160
// Blend mode ALPHA_BLENDING is used for UI elements, so we don't premultiply alpha here.
161-
return vec4(color.rgb, color.a * t);
161+
return vec4(color.rgb, saturate(color.a * t));
162162
}
163163

164164
fn draw_background(in: VertexOutput) -> vec4<f32> {
@@ -168,7 +168,7 @@ fn draw_background(in: VertexOutput) -> vec4<f32> {
168168
// When drawing the background only draw the internal area and not the border.
169169
let internal_distance = sd_inset_rounded_box(in.point, in.size, in.radius, in.border);
170170
let t = antialias(internal_distance);
171-
return vec4(color.rgb, color.a * t);
171+
return vec4(color.rgb, saturate(color.a * t));
172172
}
173173

174174
@fragment

0 commit comments

Comments
 (0)