Resolution(Strech Mode): 2D vs. Viewport

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By Yugo
:warning: Old Version Published before Godot 3 was released.

I would like my game to look sharp on mobile devices(tablets, 3.5Inch to 10inch)

So I looked at this tutorial:

I don’t get which Stretch Mode I should use. When should I use 2D and when Viewport?

I really just want sharp asstes on the devices.

:bust_in_silhouette: Reply From: Calinou

I really just want sharp assets on all devices.

Your best bet is using the disabled scaling mode, and using high-resolution assets (since Godot does not support vectors directly, like SVG).

A good bet is using assets that have 2× higher resolution than needed on typical screens (eg. if a sprite covers a 64x64 area in the project, then import a 128x128 image), although it still won’t be enough for screens with extremely high DPI (some devices can reach over 500 DPI!). If you design your sprites using vector software, it is very easy to export high-resolution versions.

That said, here’s the difference between disabled, 2d and viewport scaling modes:

  • disabled: while the framebuffer will be resized to match the game window, nothing will be upscaled or downscaled (this includes GUIs).
  • 2d: the framebuffer is still resized, but GUIs can be upscaled or downscaled. This can result in blurry or pixelated fonts.
  • viewport: the framebuffer is resized, but computed at the original size of the project. The whole rendering will be pixelated. You generally do not want this, unless it’s part of the game style.

I modified my question. I want it to look good on all mobile devices, because for desktop I will make a different version of the game.

So for how many resolutions should I then export the asstes from my vector program, if I target (only) mobile devices?

Yugo | 2016-03-08 22:19

As I said, you can just use really high-resolution images and it’ll look good anywhere, but it won’t be efficient on low-DPI devices (which are not that common in the mobile space today).

Godot is able to lower image resolution on export, but I haven’t dived into that yet.

Calinou | 2016-03-08 22:56

:bust_in_silhouette: Reply From: batmanasb

Scaling is a nightmare, scary stuff. I’ve been trying to tackle scaling to different aspect ratios with no avail, I don’t think it can ever be perfect. But my most recent achievement is to disable stretching and instead adjust the zoom level of a camera based on the size of the viewport (aka resolution of the game window). Although this was only intended for side scrolling games, it sounds like it should also be fine for non-moving camera games. More details here: reddit post

Thanks for this. Although I haven’t yet tested this particular solution, I have found many of your posts and code snippets on Godot QA and Reddit to be very helpful.

ericdl | 2016-06-14 04:10

Thanks, I’m still learning and hope to contribute back to the Godot community as best as I can :slight_smile:

batmanasb | 2016-06-14 09:39