-
-
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
Ui border is 1 pixel too large, or is getting aliased. #13503
Comments
The issue still exists on both of those commits, with debcf3f looking slightly different. |
looking into this rn. I think there's a bug with how the sdfs are calculated. Visualizing external_distance(left) and internal_distance(right). We see a darker red around the external_distance. It being darker is saying that the outside pixel is half in and half out of the border, but it should be bright red saying that the outside pixel is fully part of the border. I think the calculations are off by half a pixel somewhere, but not sure how to fix it yet. |
Thanks for working on this issue! That looks much better, but there is still 1px of the border bleeding into the middle on some sides of some of those squares. It is visible only on the top right black/white square, the 2 green/orange, and the 2 purple/yellow squares. Is this an artifact caused by the screenshot? |
Not an artifact. Here's a blown up screenshot. For this I changed border_distance to be let border_distance = select(external_distance, -internal_distance, internal_distance <= 0); Which is more correct than it was before, but probably still a little wrong. I'll see if I can come up with a better formula. |
# Objective - Fixes #13503 - Fix other various bugs I noticed while debugging above issue. ## Solution - Change the antialiasing(AA) method. It was using fwidth which is the derivative between pixels, but there were a lot of artifacts being added from this. So just use the sdf value. This aa method probably isn't as smooth looking, but better than having artifacts. Below is a visualization of the fwidth.  - Use the internal sdf for drawing the background instead of the external sdf and extract the border for these type of nodes. This fixed 2 bugs, one with the background coloring the AA pixels on the edge of rounded borders. And also allows for the border to use a transparent color. - Don't extract borders if all the widths are zero. ## Testing - played a bunch with the example in the linked issue. This PR:  Main:  - ran the `borders` and `rounded_borders` examples --- ## Changelog - Fixed various antialiasing issues to do with rounded ui borders. --------- Co-authored-by: Alice Cecile <alice.i.cecile@gmail.com> Co-authored-by: Andreas Weibye <13300393+Weibye@users.noreply.github.com>
Bevy version
Main, commit 0ec6347
Relevant system information
What you did
Create a NodeBundle with a 1 pixel wide border on all sides.
What went wrong
The border appears to be 1 pixel too large on all sides, or is getting aliased, causing it to blend into the node's background. I would expect a 1 pixel border to be exactly 1 pixel on the screen(see the 0.13.2 screenshot below).
This gist reproduces the issue on commit 0ec6347.
And this gist does not show the issue on 0.13.2.
Possible Fix
I'm not at all fluent with shader code, but while poking around in ui.wgsl, I found that on line 161, changing
external_distance < internal_distance
toexternal_distance > internal_distance
fixes the issue. After doing that, the border appears exactly the same as the 0.13.2 screenshot below. I have no idea what the implications are for making that change, so it may very well break other things.True scale:

Scaled up to highlight issue:

Expected(using bevy 0.13.2):

The text was updated successfully, but these errors were encountered: