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

Scaling viewport appropriately #111

Merged
merged 7 commits into from
Mar 12, 2024
Merged

Conversation

FailSpy
Copy link
Contributor

@FailSpy FailSpy commented Mar 12, 2024

When you change your resolution, this PR makes it actually change the Viewport's render resolution, for both 3D and UI.
This means when you choose 1920x1080, you will actually be rendering at 1920 x 1080 (unless you change your render scale, then your UI is rendering at 1080p, but your 3D is rendering at the specified scale :P)

This includes @grgp's changes at #90 for GUI scaling, which while I think less necessary now with the display resolution rendering scaling up the UI better, @grgp's GUI scale slider makes it so people can choose what size they're comfortable with.
Worth noting, the GUI scale slider will not change the rendering resolution of the UI, merely just scale up or down the pixels that are already there. Without doing a whole SubViewport thing, or greatly sacrificing 3D rendering, best I can tell this is not possible.

Addresses #81

Copy link
Owner

@Phazorknight Phazorknight left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This works great! Thanks so much for this.

I actually think I have a decent solution for improving the GUI scaling but will make that a separate commit.

@Phazorknight Phazorknight merged commit 6381b4d into Phazorknight:main Mar 12, 2024
@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 12, 2024

I'll be very curious to see the solution! If you can explain it I'd also be happy to have a shot at implementing it.

@Phazorknight
Copy link
Owner

I've included it in 003d035
Simply put it's just setting the Project's window stretch mode to "canvas_items" which improves the UI scaling behaviour.

It's not pixel perfect, noticeably reduces the aliasing that was present beforehand, making it a "good enough" option in my book.

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

@Phazorknight canvas_items doesn't do what you think it does. I agree with you it should do UI scaling, but it doesn't.

It will actually change the viewport render resolution to be whatever you scaled the window to, and has the canvas items render layout reflect that to be similar to the requested resolution. To demonstrate what I mean, here's a fullscreen screenshot of me allegedly running at 320x180, with the window resized to my screen resolution at 2560x1440 with the canvas_items option selected:

image

So really, the game is rendering at 2560x1440, despite my requested resolution at '320x180'.

And just for fun, here's the same situation, however it's running with the viewport option selected.
image

@Phazorknight
Copy link
Owner

Darn it. 😖 I'll reopen the issue and will undo the project stretch mode setting.

@FailSpy
Copy link
Contributor Author

FailSpy commented Mar 13, 2024

@Phazorknight Yeah, I really was disappointed as well. Would've been nice for Godot to just... support pure 2D scaling like that. 😭

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

Successfully merging this pull request may close these issues.

3 participants