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

Text gets blurry when resizing the viewport with the canvas_items stretch mode #86563

Open
Kyrio opened this issue Dec 27, 2023 · 13 comments
Open

Comments

@Kyrio
Copy link

Kyrio commented Dec 27, 2023


Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Tested versions

  • Reproducible in: v4.2.1.stable.official [b09f793]
  • Also reproducible in: v4.1.3

System information

Godot v4.2.1.stable - Windows 10.0.19045 - GLES3 (Compatibility) - NVIDIA GeForce GTX 950M (NVIDIA; 31.0.15.3118) - Intel(R) Core(TM) i5-6300HQ CPU @ 2.30GHz (4 Threads)

Issue description

One of the main advantages of the canvas_items stretch mode (née 2d) is that it scales the UI automatically while keeping the shapes and fonts crisp at any window size. It's particularly useful when you want to keep the same size ratios in your UI regardless of resolution. This is illustrated by the attached project, which I've created for both Godot 3 and Godot 4.

Here are two screenshots taken on Godot 3 (view them at 100% size to get a better idea):

The text remains crisp in Godot 3 when the viewport size increases or decreases.

image

However, in Godot 4, the behavior is different and fonts get slightly blurry at any resolution other than the viewport size defined in the settings.

image

The same behavior can be observed when resizing to a smaller viewport size, with blur being particularly noticeable.

  • Godot 3.5.3: image
  • Godot 4.2.1: image

Steps to reproduce

  1. Load the Godot 4 MRP
  2. Run the project, the default viewport size is 1024x576
  3. Resize the window or expand it, or set the project to run fullscreen
  4. Notice that the text is crisp at the base resolution, but blurry at smaller/larger resolutions
  5. You can compare with the Godot 3 project where fonts remain crisp regardless

Minimal reproduction project (MRP)

@Calinou
Copy link
Member

Calinou commented Jan 1, 2024

For reference, I was able to confirm this on my end. It seems to be related to how font oversampling works, possibly rounding in an incorrect manner. Changing font hinting settings in the import dock doesn't resolve the issue.

cc @bruvzg

@bruvzg bruvzg self-assigned this Jan 2, 2024
@conde2
Copy link

conde2 commented Feb 21, 2024

I'm having the same problem and can confirm it:

v4.2.1.stable.mono.official [b09f793]

image
image
image
image
image

Here is a Minimal reproduction project (MRP)

Bug.zip

@Calinou
Copy link
Member

Calinou commented Feb 21, 2024

@conde2 This is an unrelated issue: #54030

@conde2
Copy link

conde2 commented Feb 21, 2024

@Calinou, maybe its related to both, I realized that the entire UI gets blurry too, is it supposed to happen?

image

Just try with my MRP, just by changing the resolution the UI is all blurry

@conde2
Copy link

conde2 commented Feb 29, 2024

Ok after some research I found a topic in godot forum with the same problem I had:

https://forum.godotengine.org/t/blury-text-on-label/42452/2

After changing this settings I was able to get my game running crystal clear, not blurry interface and text
For anyone having the same problem, here is the settings I had to change:

theme/default_font_hinting=2
theme/default_font_multichannel_signed_distance_field=true
theme/lcd_subpixel_layout=0

@Calinou
Copy link
Member

Calinou commented Feb 29, 2024

Ok after some research I found a topic in godot forum with the same problem I had:

The issue you're encountering is different from the issue reported here. When zooming in the 2D editor, fonts are not re-rasterized as this could be extremely slow at high zoom levels. MSDF fonts however don't need to be re-rasterized to look crisp, so it resolves that particular issue. However, MSDF fonts don't address the problem outlined here for non-MSDF fonts (they are supposed to be perfectly crisp at 100% scaling).

For anyone having the same problem, here is the settings I had to change:

Note that when you enable MSDF font rendering, font hinting and LCD subpixel layout settings are ignored, so you don't need to change these.

@conde2
Copy link

conde2 commented Feb 29, 2024

I understand, Im using the default fonts from godot 4.2 so It's definitely other problem. Should I open a new issue then?

Also I just want to add to the topic that the blurry was not in the editor it was in the game itself and after changing this settings the GAME become crystal clear.
So maybe this settings are affecting the game and shouldn't? For example in the GUI settings if you change the tooltip delay it also changes the in game tooltip delay.

If this is the way it's supposed to be I believe this option should be enabled by default or stated in the docs more clearly.

@Calinou
Copy link
Member

Calinou commented Feb 29, 2024

I understand, Im using the default fonts from godot 4.2 so It's definitely other problem. Should I open a new issue then?

This was already talked about a while ago, and was considered to not be a bug as we can't resolve it without excessive performance overhead: #69711

On top of that, it could be argued that re-rasterizing DynamicFonts when you zoom in the editor would be misleading as this behavior wouldn't occur when running the project and zooming with a Camera2D.

So maybe this settings are affecting the game and shouldn't? For example in the GUI settings if you change the tooltip delay it also changes the in game tooltip delay.

MSDF fonts can improve font appearance in the running project if you change Camera2D zoom. This is expected behavior, since it's how MSDF fonts work: they are rasterized once, and a shader is used to interpolate smooth curves from the signed distance field data.

If this is the way it's supposed to be I believe this option should be enabled by default or stated in the docs more clearly.

MSDF fonts have several limitations outlined in the documentation and don't look great at small sizes, so we can't make them the default.

@hhyyrylainen
Copy link

I have an issue with only tooltips becoming blurry. All other text and custom tooltips that we have implemented in Thrive (but made to look basically like the inbuilt ones) look fine when scaled and even their borders are non-blurry. So only inbuilt tooltips experience blurriness problems in text and their borders also look pixelated so it is not only the text that is impacted.

Should I open a separate issue about that? I couldn't find any issues specifically about blurry tooltips.

@Calinou
Copy link
Member

Calinou commented Jun 12, 2024

I have an issue with only tooltips becoming blurry.

This is already being tracked in #54030.

@hhyyrylainen
Copy link

Thanks. I did see that issue before but there was so much discussion that I couldn't see that it would also be relevant for tooltips.

@d782

This comment has been minimized.

@pochoco24
Copy link

Having the same issue when changing Window>Stretch>Scale in Project Settings with the disabled stretch mode. (Non-game applications use disabled stretch mode)

I have text with font size of 16px. When changing the stretch scale to 1.25x, the font would be 20px, but it looks blurry even though the font size is being scaled to an integer.

@adamscott adamscott changed the title Text gets blurry when resizing the viewport with the canvas_items stretch mode Text gets blurry when resizing the viewport with the canvas_items stretch mode Nov 30, 2024
@github-project-automation github-project-automation bot moved this to For team assessment in Rendering Issue Triage Dec 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: For team assessment
Development

No branches or pull requests

7 participants