-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
UI anti-aliasing fix #16181
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 anti-aliasing fix #16181
Conversation
|
@ickshonpe is this ready or is it still a draft? |
Ready for review now, though the implementation sucks so much as it passes in the inverse scale factor with every vertex 😓. That could be removed later by switching to physical coordinates internally in a follow up. I've got some before and after test examples but I need to go to sleep, I'll put them up when I wake up. |
UI Anti-aliasing is incorrectly implemented. It always uses an edge radius of 0.25 logical pixels, and ignores the physical resolution. For low dpi screens 0.25 is is too low and on higher dpi screens the physical edge radius is much too large, resulting in visual artifacts. Multiply the distance by the scale factor in the `antialias` function so that the edge radius stays constant in physical pixels. To see the problem really clearly run the button example with `UiScale` set really high. With `UiScale(25.)` on main if you examine the button's border you can see a thick gradient fading away from the edges: <img width="127" alt="edgg" src="https://github.com/user-attachments/assets/7c852030-c0e8-4aef-8d3e-768cb2464cab"> With this PR the edges are sharp and smooth at all scale factors: <img width="127" alt="edge" src="https://github.com/user-attachments/assets/b3231140-1bbc-4a4f-a1d3-dde21f287988">
# Objective UI Anti-aliasing is incorrectly implemented. It always uses an edge radius of 0.25 logical pixels, and ignores the physical resolution. For low dpi screens 0.25 is is too low and on higher dpi screens the physical edge radius is much too large, resulting in visual artifacts. ## Solution Multiply the distance by the scale factor in the `antialias` function so that the edge radius stays constant in physical pixels. ## Testing To see the problem really clearly run the button example with `UiScale` set really high. With `UiScale(25.)` on main if you examine the button's border you can see a thick gradient fading away from the edges: <img width="127" alt="edgg" src="https://github.com/user-attachments/assets/7c852030-c0e8-4aef-8d3e-768cb2464cab"> With this PR the edges are sharp and smooth at all scale factors: <img width="127" alt="edge" src="https://github.com/user-attachments/assets/b3231140-1bbc-4a4f-a1d3-dde21f287988">
# Objective UI Anti-aliasing is incorrectly implemented. It always uses an edge radius of 0.25 logical pixels, and ignores the physical resolution. For low dpi screens 0.25 is is too low and on higher dpi screens the physical edge radius is much too large, resulting in visual artifacts. ## Solution Multiply the distance by the scale factor in the `antialias` function so that the edge radius stays constant in physical pixels. ## Testing To see the problem really clearly run the button example with `UiScale` set really high. With `UiScale(25.)` on main if you examine the button's border you can see a thick gradient fading away from the edges: <img width="127" alt="edgg" src="https://github.com/user-attachments/assets/7c852030-c0e8-4aef-8d3e-768cb2464cab"> With this PR the edges are sharp and smooth at all scale factors: <img width="127" alt="edge" src="https://github.com/user-attachments/assets/b3231140-1bbc-4a4f-a1d3-dde21f287988">
Objective
UI Anti-aliasing is incorrectly implemented. It always uses an edge radius of 0.25 logical pixels, and ignores the physical resolution. For low dpi screens 0.25 is is too low and on higher dpi screens the physical edge radius is much too large, resulting in visual artifacts.
Solution
Multiply the distance by the scale factor in the
antialiasfunction so that the edge radius stays constant in physical pixels.Testing
To see the problem really clearly run the button example with
UiScaleset really high. WithUiScale(25.)on main if you examine the button's border you can see a thick gradient fading away from the edges:With this PR the edges are sharp and smooth at all scale factors: