-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix various bugs with UI rounded borders #13523
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good to me, nice and clean implementation.
// Both vertical and horizontal percentage border values are calculated based on the width of the parent node | ||
// <https://developer.mozilla.org/en-US/docs/Web/CSS/border-width> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
layout and style is a complex topic, having these comments that refers back to source material helps a lot, thanks!
let parent_width = parent | ||
.and_then(|parent| node_query.get(parent.get()).ok()) | ||
.map(|parent_node| parent_node.size().x) | ||
.unwrap_or(ui_logical_viewport_size.x); | ||
let left = | ||
resolve_border_thickness(style.border.left, parent_width, ui_logical_viewport_size); | ||
let right = | ||
resolve_border_thickness(style.border.right, parent_width, ui_logical_viewport_size); | ||
let top = | ||
resolve_border_thickness(style.border.top, parent_width, ui_logical_viewport_size); | ||
let bottom = | ||
resolve_border_thickness(style.border.bottom, parent_width, ui_logical_viewport_size); | ||
|
||
let border = [left, top, right, bottom]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All of this makes sense and is straightforward to read 👍
Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
# 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">
# Objective - since #13523, UI is broken in WebGPU ``` Compilation log for [Invalid ShaderModule (unlabeled)]: 1 error(s) generated while compiling the shader: :108:27 error: 'textureSample' must only be called from uniform control flow let texture_color_1 = textureSample(sprite_texture, sprite_sampler, in_2.uv); ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ :151:19 note: called by 'draw_background' from 'fragment' let _e5 = draw_background(in); ^^^^^^^^^^^^^^^^^^^ :147:5 note: control flow depends on possibly non-uniform value if _e3 { ^^ :146:23 note: parameter 'in' of 'fragment' may be non-uniform let _e3 = enabled(in.flags, BORDER); ``` ## Solution - call `textureSample` from outside the if. both branches are using the same parameters
Objective
Solution
Testing
played a bunch with the example in the linked issue.


This PR:
Main:
ran the
borders
androunded_borders
examplesChangelog