-
Hi! TLDR; When integrating Long story: This is my first time using for i in 0..10 {
let i = i as f32;
let offset: f32 = i / 10. + 10. * i;
ui.painter().line_segment(
[
egui::pos2(10., offset + 10.),
egui::pos2(100., offset + 10.),
],
egui::Stroke::new(1., egui::Color32::WHITE),
);
ui.painter().line_segment(
[
egui::pos2(200. + offset, 10.),
egui::pos2(200. + offset, 100.),
],
egui::Stroke::new(1., egui::Color32::WHITE),
);
} I can see the 5th line (counting from 0) to be the brightest one. When I copy&paste the same code into I'm using the latest git checkouts, one pixel per point. I've tried the latest and also more ancient versions of both Bonus question: when I draw something at (10, 10) -- is it the center of the pixel or its upper left corner? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Hello!
Egui should work with either texture filtering mode. In particular, If you are on a display with one physical pixel per point, then the default monospace font (at size 13) should look pixel-perfect with all pixels either perfectly on or off (even with bilinear sampling). Like this: Magnified: When painting anything but text, Egui doesn't use textures at all (it just samples the (0,0) texel which is pure white). In particular, the There is currently no option to turn off anti-aliasing (oops!) unless you bypass
Upper left corner. In particular, if you paint a rectangle that has min=(10,10) and max=(11,11), then that rectangle will be exactly one pixel wide. I added a test to verify this in e105719 On my 1 pixel_per_point display this produces pixel-perfect squares: This is the logical choice, as it means that a window that is 1000 pixels wide has coordinates ranging from Depending on the rendering backend you may need to offset either the positions or the uvs by 0.5 pixels/texels. Good luck! |
Beta Was this translation helpful? Give feedback.
-
Thank you, the explanation and those reference screenshots really helped! If I do the "monospace" test it looks the same (except I'm using It might be just me but I expected Update: I played with 0.5 pixel offsets in vertex and/or uvs and it seems like the default offsets of 0 are the best. Perhaps the font size is too small to be clear and what I see is the expected result. Well, unless I'm doing something else wrong, which is a strong possibility. 😃 Update 2 (sorry!) I've tried to use I think I might be trying to bite off more than I can chew! And maybe I should just switch to Oops, Update3: I think I finally found the problem -- it's the shaders. When I tried to reuse the one you use in Glium I was gettign the results above. When I removed the sRGB code and implemented the fragment shared from the outdated miniquad example (RGB are all the same in the texture) the output looks right and text is readable even with the default gray font. Being the noob I am, what is the sRGBA calculation useful for? |
Beta Was this translation helpful? Give feedback.
-
FYI: I'm working on an update to the miniquad integration in not-fl3/egui-miniquad#5 |
Beta Was this translation helpful? Give feedback.
Hello!
Egui should work with either texture filtering mode. In particular,
egui_glium
andegui_web
both use bilinear filtering, but sample the texels right in the middle anyway, so it doesn't matter.If you are on a display with one physical pixel per point, then the default monospace font (at size 13) should look pixel-perfect with all pixels either perfectly on or off (even with bilinear sampling). Like this:
Magnified:
When painting anything but text, Egui doesn't use textures at all (it just samples the (0,0) texel which is pure white). In particular, the
line_segment
example you showed…