How to get scaling to work properly in fullscreen

Godot Version

4.2

Question

I am making a pixel art game with a viewport size of 800x400 and a camera zoomed 2x for pretty much every scene in the game. I want it to be locked to a 4x3 aspect ratio and fit to your monitor size vertically but have black bars on the sides if necessary.

These are my viewport settings:


If I leave scale mode on fractional than the game goes to the correct size and fits perfectley with my monitor vertically with black bars on the sides like I want. But leaving it like that makes some pixels look weird and bigger than others. Leaving it on integer makes all of the pixels look perfect but if I go fullscreen I have black bars along the top and bottom too (which I dont want)

These issues go away if I set the game to FULLSCREEN instead of EXCLUSIVE_FULLSCREEN but then theres a grey border around the whole screen.

In summary, how can i have my game fit my monitor like this:


Without having any weird pixel scaling issues or grey borders

1 Like

Hey I’m running into the same exact issue for my 4:3 aspect ratio pixel art game. Did you find a solution?

This is due to how the Fullscreen mode works. It intentionally leaves a 1-pixel border on each side of the screen, which makes the window 1918×1076 instead of 1920×1080 (on a 1080p display). This can reduce the integer scale factor that ends up being used. Use black border color in borderless fullscreen mode on Windows by Calinou · Pull Request #88734 · godotengine/godot · GitHub makes the border black so it’s less intrusive, but it will not resolve this integer scaling issue on its own.

However, you should use the Exclusive Fullscreen mode for games as it allows for lower latency. See the note in the documentation:

There’s more explanation in this GitHub issue:

Thanks for the reply! So even with exclusive fullscreen I have a fairly large black border on the top, bottom, and sides (I’m okay with the side borders). This is larger than 1 pixel so maybe we are talking about a separate issue? I’m using a 1920 by 1080 monitor and my viewport is 1280 by 960, which is a 4:3 ratio. Here’s an example screenshot:

So I believe what OP and I are asking is whether it’s possible to get rid of the top and bottom borders of our 4:3 ratio pixel art games while keeping the Window Stretch settings like this to ensure high pixel art quality:

Additionally, I saw that the Multiple Resolutions docs suggests to
use a 640 x 360 ratio to scale to 1920 x 1080 without any black bars. However, I adjusted my viewport to 640 x 360, and I still have the black bars on top, bottom, and sides.

If your previous response covers this, and I’m totally missing the point please let me know, thanks for your help and patience!

With integer scaling, your viewport can be 1280×960, 2560×1920 and so on. It can’t be any intermediate size. This is why you see black bars appear on all sides. A lot of modern pixel art games use a 640×360 viewport as it covers a lot of common screen resolutions with integer scaling (720p, 1080p, 1440p and 2160p are all covered).

1280×960 is a very large viewport size for a pixel art game, as it won’t be able to fit on the Steam Deck which is 1280×800.

If you want to use the full screen while using integer scaling, you need to adjust the viewport size according to the window size. This can be done using a script, but keep in mind doing this will affect the viewable game area (i.e. people might be able to see more of the game world depending on their window size).

If you want pixel art to look reasonably sharp while not being distorted, you can use a sharp bilinear filter while using fractional scaling. It won’t be as sharp as integer scaling though.

Did you use the Exclusive Fullscreen mode while testing this? Try running the Multiple Resolutions demo project to see for yourself how it can work.

2 Likes

Your detailed, helpful reply is much appreciated!

What you said about the intermediate sizing makes sense

Looks like I had an addon that was causing the black bars to show even with a viewport of 640 x 360

So I’ll have to experiment with either scaling my game down to 640 x 360 and using integer scaling, or using your sharp bilinear suggestion with fractional scaling

As a side note, I was able to get a good display when exporting the game to my steam deck using the 1280 by 960 viewport but with maximized instead of exclusive fullscreen. I’m sure there’s likely a negative consequence of this that I’m not aware of yet

In hindsight I definitely should’ve looked into resolution specifics before creating the game, but you live and you learn. Thanks again!