Lower 3D resolutions without messing up ui?

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

in my game I want test lowering the 3d resolution to improve performance as stated in the docs:

If Stretch Mode is set to something other than Disabled, the size of
the root viewport is scaled down by the Shrink factor, and pixels in
the output are scaled up by the same amount. This is rarely useful for
2D games, but can be used to increase performance in 3D games by
rendering them at a lower resolution.

This is e.g. how my main menu in the game looks like:
enter image description here
I’ve set my stretch mode to “2d” and the aspect to “expand” in the project settings, which is working fine.
Now I want the 3d resolution to be lowered. When I set the shrink value up, my 3d render resolution is correctly lowered, but my ui is messed up:
enter image description here

How can I achieve the lower 3d resolution without scaling the ui?

:bust_in_silhouette: Reply From: Calinou

How can I achieve the lower 3d resolution without scaling the ui?

You need to use two viewports. This means you’ll need to create one Viewport node, as Godot will automatically create a viewport for you (it’s often called the “root viewport”).

The root viewport will render 2D elements, whereas the Viewport node will render the 3D scene. This way, the Viewport node can have its resolution decreased without affecting 2D elements.

There is a demo that showcases this here: https://github.com/godotengine/godot-demo-projects/tree/master/viewport/3d_scaling