1
\$\begingroup\$

I'm making a Mario-Like platformer in Godot, and am going for a N64 style, and I want to lower the resolution of the render, while still having the window being resizable, like in Blender. Is there any way to do this?

Thanks in advance!

\$\endgroup\$
2
\$\begingroup\$

Simpler approach is to set "Stretch Mode" (in project settings under Display -> Window -> Stretch) to "Viewport".

With "Stretch Mode" set to "Viewport", the rendered resolution will match the design resolution (in project settings, under Display -> Window -> Size). This may result in enlarged "pixels".

Adjust "Aspect" (in project settings under Display -> Window -> Stretch) to the behavior you want (e.g. "Keep" will keep the aspect ratio, but may introduce black bars, but "Ignore" may use rectangular "pixels").

Refer to the article Multiple resolutions for details.


If you want to change the resolution of the Viewport at runtime, you can do the following:

    var root =  get_tree().root;
    root.size = Vector2(100,100);

Note: store the root in a variable, then edit it. Trying to edit it directly will result in a runtime error. This is a bug.

The following code also works:

    $"/root".size = Vector2(100,100);

Which is equivalent to:

    get_node("/root").size = Vector2(100,100);

You can also change the size of the window from code like this:

    OS.window_size = Vector2(100,100);
\$\endgroup\$
3
  • \$\begingroup\$ Thank you! It works great! \$\endgroup\$
    – jort57
    Feb 16 at 18:07
  • 1
    \$\begingroup\$ Note that if you need additional control (mainly for 3D games when you want crisp UI but low-resolution 3D rendering), you need to use a second Viewport node for the 3D rendering as done in the 3D Viewport Scaling demo. For 2D, the approach described in the answer is fine, except that you may want to add a script to enforce integer scaling for pixel art games. \$\endgroup\$
    – Calinou
    Mar 7 at 13:23
  • \$\begingroup\$ @jort57 tagging you so you see Calinou comment. I never intended to suggest this answer was the only way to go about it, nor that it would work for all situations, just that it is simpler. \$\endgroup\$
    – Theraot
    Mar 7 at 14:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.