Updating other viewports on main window/viewport resize

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By fractile

I have a scene for rendering a HUD containing following hierarchy:

Spatial

  • Viewport (fixed size)
    • Control (with script to draw the HUD contents)
  • MeshInstance (QuadMesh with material using ViewportTexture)

This scene is instantiated in front of player camera in the main scene.

It all works well until I switch to full-screen mode or resize the main window. After that all characters in the HUD show up as rectangles: https://i.imgur.com/r0Mt1qn.png

I found out that calling Control’s update() method manually after main window resize fixes the texts. That leads to the questions:

  1. Why does resizing main viewport require updating other viewports and why does that not happen automatically? Am I doing something wrong here?

  2. Where should I call the update() method? As this viewport is not resized, I’m not getting any resize signals or notifications within this scene. Listening to main viewport size changes and manually updating all other viewports feels a bit hacky solution…

:bust_in_silhouette: Reply From: Calinou

Why does resizing main viewport require updating other viewports and why does that not happen automatically? Am I doing something wrong here?

This is likely due to DynamicFont oversampling. To work around this, try disabling Rendering > Quality > Dynamic Fonts > Use Oversampling in the Project Settings.

You’re right, that fixed the initial problem.

Do you know if this behavior with font oversampling is a “feature” or something that gets eventually fixed?

fractile | 2020-03-24 09:28

It stems from a limitation of the font oversampling system which only supports a single global font scale factor, rather than a per-viewport (or per-node) scaling factor. I don’t know if it will be fixed anytime soon though.

Moving to distance field fonts would remove the need for font oversampling techniques, but these are also more computationally expensive to render.

Calinou | 2020-03-24 14:55

That’s good to know, thanks. This workaround is good enough for me, at least for now.

fractile | 2020-03-24 18:33