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

Update viewport scaling demo to 4.0. #891

Closed
wants to merge 1 commit into from

Conversation

rcorre
Copy link
Contributor

@rcorre rcorre commented Mar 18, 2023

Fixes #856.

The 3d_scaling demo was updated to use the built-in 3D scaling mechanisms
in the Forward+ renderer.

A new 3d_scaling_compat demo was added to demonstrate the legacy
SubViewport-based scaling method for the Compatibility renderer.


Renderer: Compatibility

Check out this demo on the asset library: https://godotengine.org/asset-library/asset/586
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Do we need a new asset library entry?

Copy link
Member

@Calinou Calinou Mar 19, 2023

Choose a reason for hiding this comment

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

Yes. 4.0 demos haven't been submitted for the asset library yet, but we intend to keep the 3.x demos available for the foreseeable future.

In the meantime, you can remove the "Check out this demo on the asset library" line as it'll need to have its URL changed once the demo is submitted.

@Calinou
Copy link
Member

Calinou commented Mar 29, 2023

I've pushed additional commits to https://github.com/Calinou/godot-demo-projects/tree/rcorre-update-viewport-scaling-demos to improve the demos in various ways, but the 3D Resolution Scaling (Compatibility) demo needs to resize the SubViewport when the window size changes. Otherwise, 3D rendering becomes pixelated or blurry once you increase the window size (which is unexpected from an user perspective, as we're using the canvas_items stretch mode).

I haven't been able to figure this out yet because you can't change a SubViewport's size when Stretch is enabled on the parent SubViewportContainer. We may end up having to disable Stretch and implement scaling ourselves, similar to what the 3D in 2D demo does.

@rcorre
Copy link
Contributor Author

rcorre commented Mar 29, 2023

but the 3D Resolution Scaling (Compatibility) demo needs to resize the SubViewport when the window size changes

Huh, I figured that would happen automatically with Stretch enabled. I added this print:

get_tree().root.size_changed.connect(func(): prints(get_tree().root.size, viewport_container.size, viewport.size))

The viewport is resizing to the parent control, but the way the parent control resizes depends on the window/stretch/mode and window/stretch/aspect settings in the project. If you set mode=disabled, then the viewport container and the viewport auto-adjust to the window size.

@leetNightshade
Copy link

leetNightshade commented Sep 21, 2023

Idk if it's just me, but testing this on Godot 4.1.1.stable.custom_build on Steam Deck doesn't seem to do anything, it draws at the window resolution. I have this same problem in my project that emulates this subviewport project; and my project already handles size_changed.

Oh I guess related to this: godotengine/godot#72548

viewport/3d_scaling/hud.gd Show resolved Hide resolved
viewport/3d_scaling_compat/hud.gd Outdated Show resolved Hide resolved
viewport/3d_scaling_compat/hud.gd Outdated Show resolved Hide resolved
viewport/3d_scaling/hud.gd Show resolved Hide resolved
viewport/3d_scaling/hud.gd Show resolved Hide resolved
viewport/3d_scaling_compat/hud.gd Outdated Show resolved Hide resolved
@Calinou
Copy link
Member

Calinou commented Feb 7, 2024

godotengine/godot#83976 is landing in 4.3, so I'd prefer we just use the 3D scaling method for all rendering methods now. This way, there's only one way to achieve it in a way that doesn't lock you from switching rendering methods later on (or makes you use a suboptimal approach on Forward+/Mobile).

The separate-viewport scaling method is still worth documenting for 2D usage, but it's more niche in comparison, so it should remain in its separate demo and should cover 2D rendering instead. This mean it would have to be redone from scratch.

Fixes godotengine#856.

The 3d_scaling demo was updated to use the built-in 3D scaling mechanisms
in the Forward+ renderer.

A new 3d_scaling_compat demo was added to demonstrate the legacy
SubViewport-based scaling method for the Compatibility renderer.

Co-authored-by: A Thousand Ships <[email protected]>
@rcorre
Copy link
Contributor Author

rcorre commented Feb 8, 2024

I updated to only include the builtin scaling demo, and removed the 3D compat demo.
I'm not as familiar with 2D, so I didn't attempt to create a 2D scaling demo.

@Calinou
Copy link
Member

Calinou commented Feb 13, 2024

Merged manually with 722bd11 (which includes some visual and UI improvements to make scaling more noticeable). Thanks!

Screenshot

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

Successfully merging this pull request may close these issues.

3D Scaling in 4.0-dev not working
5 participants