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

Assets are being distorted on monitors that are not a 16 * 9 aspect ratio when Window is on Viewport / Expand mode #63579

Closed
Tekuzo opened this issue Jul 28, 2022 · 6 comments · Fixed by godotengine/godot-docs#5996

Comments

@Tekuzo
Copy link

Tekuzo commented Jul 28, 2022

Godot version

v3.4.4.stable.official [419e713]

System information

M1 Macbook Air 2020

Issue description

I am working on a project that is going to be released on Mobile and on PC / Mac / Linux.

Following the documentation here, I put my Stretch Mode to Viewport and the Aspect to Expand, and I have also set the base resolution of the game to 720 * 720, as I wish to support both portrait and landscape displays.

720p is a 16 * 9 resolution, and when I run my game on a 16 * 9 aspect display, the game looks pristine. But when I run my game on a monitor that has a 16 * 10 aspect ratio, there is some distortion of the assets.

Based on the documentation that I linked, the expectation is that if I have my Window settings set to Viewport / Expand, the engine is supposed to not scale the assets and instead show more of the negative space (kind of like a camera being pulled back from a subject). It seems that even on Viewport / Expand mode, some scaling is being applied to the textures and assets in the scene.

My Desktop PC has a Portrait and Landscape 1440p monitor
My laptop has a 16 * 10 monitor, which is where I see the distortion of the assets.

Here is the game running at 1440p landscape (no distortion)
Linux No Distortion

Here is the game running at 1440p portrait (no distortion)
Linux Port No Distortion

Here is the game running on my laptop at 1440 * 900 (distortion)
Screen Shot 2022-07-21 at 8 56 40 PM

You can see the distortion in the lines being drawn on the game board, and on the text.

Steps to reproduce

Start a new project, set its window size to 720 * 720
Put the Window mode on Viewport / Expand
Run the game on a monitor that has a different aspect ratio than 16 * 9

Minimal reproduction project

I have attached a sample project that can be run to see the distortion when run in full screen on a monitor that is 16 * 10.

Sample Project.zip

@Calinou
Copy link
Member

Calinou commented Jul 28, 2022

The distortion is due to fractional pixel scaling. It's not a matter of aspect ratios here, so the expand stretch aspect doesn't fix it.

The viewport stretch mode is meant to be used by pixel art games. I suggest you use the 2d stretch mode instead of viewport for your use cases.

Based on the documentation that I linked, the expectation is that if I have my Window settings set to Viewport / Expand, the engine is supposed to not scale the assets and instead show more of the negative space (kind of like a camera being pulled back from a subject). It seems that even on Viewport / Expand mode, some scaling is being applied to the textures and assets in the scene.

To disable any kind of scaling, set the stretch mode to disabled. However, this isn't recommended as 2D elements will look tiny at high resolutions. For a game, 99% of the time, 2d or viewport is what you want 🙂

If you want manual control over the size of the 2D game world depending on resolution, adjust a Camera2D node's zoom property based on window size (using the lowest dimension of width and height in your case).

@Tekuzo
Copy link
Author

Tekuzo commented Jul 28, 2022

The viewport stretch mode is meant to be used by pixel art games. I suggest you use the 2d stretch mode instead of viewport for your use cases.

My game's assets are pixel art, which is why I had the Viewport and Aspect settings set this way.

When I change the Stretch Mode to 2D from Viewport, the text starts to look better, but the lines drawn at the edges of the game board are still distorted.

Screen Shot 2022-07-28 at 11 55 30 AM

I suppose that if nothing can be done, then I will just leave it as is. I suspect that most of my users will have a 16*9 display, and this will be a moot issue.

@Tekuzo Tekuzo closed this as completed Jul 28, 2022
@Tekuzo
Copy link
Author

Tekuzo commented Jul 28, 2022

I was under the assumption that if you had the settings set to Viewport / Expand that Fractional Pixel Scaling wouldn't happen because it would only scale if it was able to maintain the aspect ratio.

@Tekuzo Tekuzo reopened this Jul 28, 2022
@Calinou
Copy link
Member

Calinou commented Jul 28, 2022

I was under the assumption that if you had the settings set to Viewport / Expand that Fractional Pixel Scaling wouldn't happen because it would only scale if it was able to maintain the aspect ratio.

Godot doesn't feature integer scaling yet. Therefore, for proper pixel art scaling, you need to install and configure https://github.com/Yukitty/godot-addon-integer_resolution_handler.

@Tekuzo
Copy link
Author

Tekuzo commented Jul 28, 2022

Ok, Thanks. I will try it out.

Should I close this issue then?

@Tekuzo
Copy link
Author

Tekuzo commented Jul 28, 2022

Thank you very much for the assistance too. It is very appreciated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants