-
Notifications
You must be signed in to change notification settings - Fork 1.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
Improve tessellation quality #5669
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5669-emilkimprove-tessellator |
@@ -611,7 +611,8 @@ impl Window<'_> { | |||
title_bar.inner_rect.round_to_pixels(ctx.pixels_per_point()); | |||
|
|||
if on_top && area_content_ui.visuals().window_highlight_topmost { | |||
let mut round = window_frame.rounding; | |||
let mut round = | |||
window_frame.rounding - window_frame.stroke.width.round() as u8; |
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.
Maybe rename rounding
to corner_radius
everywhere?
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.
Let's do it in a follow-up PR
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.
Looks great!
Defining what
Rounding
isThis PR defines what
Rounding
means: it is the corner radius of underlyingRectShape
rectangle. If you useStrokeKind::Inside
, this means the rounding is of the outer part of the stroke. Conversely, if you useStrokeKind::Outside
, the stroke is outside the rounded rectangle, so the stroke has an inner radius orrounding
, and an outer radius that is larger bystroke.width
.This definitions is the same as Figma uses.
Improving general shape rendering
The rendering of filled shapes (rectangles, circles, paths, bezier) has been rewritten. Instead of first painting the fill with the stroke on top, we now paint them as one single mesh with shared vertices at the border. This has several benefits:
The logic for rendering thin strokes has also been improved, so that the width of a stroke of
StrokeKind::Outside
never affects the filled area (this used to be wrong for thin strokes).Improving of rectangle rendering
Rectangles also has specific improvements in how thin rectangles are painted.
The handling of "Blur width" is also a lot better, and now works for rectangles with strokes.
There also used to be bugs with specific combinations of corner radius and stroke width, that are now fixed.
But why?
With the new
egui::Scene
we end up with a lot of zoomed out shapes, with sub-pixel strokes. These need to look good! One thing led to another, and then I became obsessive 😅Tessellation Test
In order to investigate the rendering, I created a Tessellation Test in the
egui_demo_lib
.Try it here