-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Filled convex polygon shapes have jagged edges #1226
Comments
You need to pass in the arguments in the correct winding order. Switching two of the points: vec![
egui::pos2(10.0, 40.0),
egui::pos2(10.0, 10.0),
egui::pos2(250.0, 50.0),
], Gives us this: This is much better, but the bottom line still doesn't look great. Rotating the points: vec![
egui::pos2(10.0, 10.0),
egui::pos2(250.0, 50.0),
egui::pos2(10.0, 40.0),
], Gives us this: The jagged edge has moved! Rotating again: vec![
egui::pos2(250.0, 50.0),
egui::pos2(10.0, 40.0),
egui::pos2(10.0, 10.0),
], It is back! I'm guessing something goes wrong with the first and last edges of the polygon. |
Yeah I assumed that the points had to be either clockwise or counterclockwise, but both gave me jaggies. So I used the most offensive looking order for the screenshot here. 😉 |
I figured out why and it has to do with how feathering (anti-aliasing) is performed. In short: the shape is both expanded and contracted, with a one-pixel wide border between. This border fades out, causing a soft edge. The contraction is the problem: for some corners it can cause self-intersecting geometry. This mostly happens for very sharp corners, which the tessellator "cuts off" so that they don't extend to much. This cutting-off worsens the problem. I need to rewrite parts of the path-tessellation to fix this properly. |
You know way more about this than I do so I can't really help you with that, but let me know if you need any help testing things. |
This comes at the cost of these corners sometimes becoming badly extruded instead. The sharper the corner, the bigger the problem. A proper fix will have to wait for later. Part of #1226
I pushed a few fixes now. The last fix comes at the cost of having sharp edges extrude weirdly, and extrude further the sharper they are. Right now I think this is less of a problem than broken anti-aliasing. A proper fix that solves both problem will have to wait until it becomes a pressing issue for someone. |
I pushed a few fixes now. The last fix comes at the cost of having sharp edges extrude weirdly, and extrude further the sharper they are. Right now I think this is less of a problem than broken anti-aliasing. A proper fix that solves both problem will have to wait until it becomes a pressing issue for someone. |
Describe the bug
The edges around the filled area of a
egui::Shape::convex_polygon()
don't have proper anti-aliasing and will appear jagged. For semi-transparent fill colors this looks as if some form of anti aliasing is taking place, but the anti-aliased pixels are drawn without the alpha channel. Opaque colors look like they are not anti aliased at all. (see the screenshots below for examples of both of these things)To Reproduce
hello_world.rs
example, and add the following add the end of theCentralPanel
:cargo run --example hello_world
.Expected behavior
The edges should appear smooth, just like drawn lines or shape strokes currently do.
Screenshots
The modified
hello_world
example mentioned above:The same example, but with a pure pure fill color without any transparency:
And the same problem with a different backend (egui-baseview):
Desktop (please complete the following information):
Additional context
Tested with the released egui 0.16.0 and with the current master branch (0.16.0-102-g2802e035).
The text was updated successfully, but these errors were encountered: