Skip to content
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

Blurry menus / scaling issues using multiple monitors #1470

Closed
jonas-schulze opened this issue Nov 24, 2021 · 5 comments · Fixed by #1494
Closed

Blurry menus / scaling issues using multiple monitors #1470

jonas-schulze opened this issue Nov 24, 2021 · 5 comments · Fixed by #1494

Comments

@jonas-schulze
Copy link
Contributor

I'm working on a 13" 2018 MacBook Pro having a WQHD monitor connected via HDMI (over a USB dock). When I try the menu example, the menu looks very blurry on the external monitor:

monitor

When I move the window to the laptop's screen, the menus look much smaller and therefore sharper as well:

macbook

#1186 is also visible when opening the upper menu.

@jkrumbiegel
Copy link
Member

GLMakie doesn't have resolution scaling yet, so there's no hidpi support per se. That's why everything is small on a hidpi monitor. Also, GLMakie text is not the sharpest to begin with because it doesn't use hinting, so some fuzzy fonts are to be expected currently. At least you can always export with CairoMakie for higher quality.

@ffreyer
Copy link
Collaborator

ffreyer commented Nov 29, 2021

I wonder what's actually causing GLMakie fonts to be blurry. It's not like large text looks blurry. Maybe we need to generate lower resolution glyphs and use them as mipmaps?

@SimonDanisch
Copy link
Member

Maybe we need to generate lower resolution glyphs and use them as mipmaps?

Yeah, that's a very good question, they should look somewhat crisp regardless of resolution - of course high-dpi will make fuzziness less obvious though...
But, I've been noticing that for a while that it can look worse than it should, but it's somewhat hard to reproduce... I'm guessing, some pixel scaling values aren't set correctly

@ffreyer
Copy link
Collaborator

ffreyer commented Nov 29, 2021

Ok I tried a few things:

I tried switching to 16x16 glyph resolution by explicitly running https://github.com/JuliaPlots/Makie.jl/blob/2faa3d75733689f2d3e802b1f623d0f90343005a/src/utilities/texture_atlas.jl#L27-L29 with appropriate values.

I tried rounding positions in https://github.com/JuliaPlots/Makie.jl/blob/2faa3d75733689f2d3e802b1f623d0f90343005a/GLMakie/src/drawing_primitives.jl#L297-L299

And I tried rounding in the vertex shader here https://github.com/JuliaPlots/Makie.jl/blob/2faa3d75733689f2d3e802b1f623d0f90343005a/GLMakie/assets/shader/sprites.vert#L119

Screenshot from 2021-11-29 18-22-32

Seems like pixel alignment is the main problem. Native (ticks use 16px fontsize by default) and high resolution glyphs look the same to me. Same with in-shader rounding vs rounding beforehand. Also interesting that libre office is so colorful, maybe that's due to dark mode? Nope, it's subpixel rendering. https://www.grc.com/ctwhat.htm

@ffreyer
Copy link
Collaborator

ffreyer commented Nov 30, 2021

I tried to make a pr to switch to pixel-aligned text rendering (https://github.com/JuliaPlots/Makie.jl/tree/ff/text) but it's not much of an improvement. Some glyphs look better, some worse, most just fuzzy somewhere else. So I tried a few different alignments (i.e. aligning vclip, it's constituents, or shifting by the antialiasing radius) and eventually I tried generating the texture atlas at a different resolution again. Turns out I didn't do that right. This is what 16 vs 64, floating vs pixel aligned looks like:

Screenshot from 2021-11-30 15-24-02

So texture resolution does matter. Here's the normal resolution plot with

16x16 glyphs (pixel aligned)

16_pixel

Note that the axis ticks have textsize = 16, matching the glyph size in the texture atlas, but the text plotted into the axis has textsize = 20. Here's the result with

20x20 glyphs (pixel aligned)

20_pixel

Comparing 16x16 and 20x20 I'd say things look best when the glyph resolution matches the textsize and downscaling is better than upscaling. Both can introduce some artifacts though. I still wouldn't say pixel aligned is strictly better... Maybe a better on average?

For reference here are glyph resolutions 16x16, 20x20, 60x60, 64x64 with and without pixel alignment.
text.zip

@ffreyer ffreyer mentioned this issue Dec 2, 2021
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants