Hello, I’m encountering some issues with the viewport scaling of my game and I’m hoping someone might be able to shed some light on what might be causing these issues.
Disclaimer: I’ve only been using Godot for about 3 weeks so I might not understand everything fully.
I’m designing my game around a 1920x1080 resolution. My pc setup is a 4k monitor as my main and (2) 1080p side monitors. Because I’m designing the game around 1080p in the editor settings I set the run/window_placement/screen to be one of my 1080p monitors. In the project settings I have the mode set to fullscreen and the stretch mode, aspect and scale all set to “disabled”, “keep”, and “1” respectively.
When I launch the game I include a print(get_viewport().size) at the start to confirm the viewport resolution. The print statement returns (2878, 1618) when run on the 1080p monitor and (3838, 2158) when run on the 4k monitor.
This poses 2 questions that I have. When run on the 4k monitor why is viewport size 2 pixels short on the x and y (should be 3840x2160)? The second question is why is when run on the 1080p monitor why is it returning a resolution that is 1.5x bigger along with the same 2 pixels short issue mentioned before.
I’ve been scratching my head on this for hours and can confirm a few things. I tested this with a brand new project and it returns same results so the issue doesn’t reside in my main game project. In the main game project I tried adjusting the the stretch settings but those seem to only affect the scaling of the sprites. The print statement still returns (2878, 1618) on the 1080p monitor.
Any insight on this issue would be very much appreciated
Do you have an OLED monitor by any chance? This may be a result of the “pixel burn-in prevention” system, where the image on the monitor shifts over time by 1-2 pixels — it is cropped for this purpose.
I do not, I did do some more testing and found that turning off “Allow hiDPI” fixes the 1.5x scaling issue on the 1080p monitor but the print statement returns (1918, 1078) so the 2 pixel reduction still persists. When I run it in windowed mode though it returns the correct (1920, 1080) probably because that’s what I’m specifying it to be so it’s definitely an issue with going into fullscreen.
I also tried running it fullscreen on the other 1080p monitor and that one also returns the (1918, 1078).
After another test I found that the resolution of the 1080p monitors is being affected by the windows resolution scale of my main 4k monitor. With the “Allow hiDPI” back on I changed my monitors display resolution in windows to be 100% (was 150%) and now the 1080p monitors return (1918, 1078) but just like the hiDPI fix it’s still reduced by 2 pixels.
I also triple checked this and set my main monitor resolution scale to be 200% and the print statement returned (3838, 2158) so I think it’s safe to say the scaling issue is 100% being caused by the windows scale resolution of my main monitor.
Is there some sort of way to have Godot ignore the scaling of my main monitor so that is doesn’t affect the other monitors?
Just tried changing it to exclusive fullscreen and you are correct! It now returns (2880, 1620) on the 1080p monitors and (3840, 2160) on the 4k monitor so that’s definitely what the problem was. Thank you very much for your help with that one!
I do, the 1080p monitors are both at 100% scaling and the 4k monitor is at 150%. That’s for sure what’s driving this problem but I just can’t seem to figure out why the resolution scale of my main monitor would affect the viewport scaling when running on the other monitors.