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

ViewportContainer not properly scaling rendering with STRETCH_MODE_2D #61301

Open
Tracked by #86837
BimDav opened this issue May 23, 2022 · 5 comments
Open
Tracked by #86837

ViewportContainer not properly scaling rendering with STRETCH_MODE_2D #61301

BimDav opened this issue May 23, 2022 · 5 comments

Comments

@BimDav
Copy link
Contributor

BimDav commented May 23, 2022

Godot version

3.x, 4.x

System information

Windows 10

Issue description

The 2 sprites in this scene
image
should be displayed the same when Control and ViewportContainer are laid out with Full Rect.

For now, when the Window stretch mode is set to STRETCH_MODE_2D, SpriteOut is correctly displayed upscaled:
image

while SpriteIn is displayed at a low resolution:
image

Steps to reproduce

See project below.

The size of the window has to be low, for example (128, 128), and the test size higher, for example (1024, 1024).

Minimal reproduction project

ViewportContainer.zip

@rpahut
Copy link

rpahut commented Oct 7, 2023

The description makes the issue look more specific and hard to encounter than I see it is. I'd describe it differently - as the viewport internal resolution is set from ViewportContainer's own logical dimensions, any time logical dimensions do not match pixel dimensions the viewport content becomes over or undersized. That would be the case for any stretch mode other than "Disable", creating more or less noticeable artefacts on every vport that is not root.

@Calinou
Copy link
Member

Calinou commented Oct 7, 2023

This is intended behavior. SubViewports do not resize automatically regardless of stretch mode. If this is added, this shouldn't be done by default to avoid breaking compatibility with existing projects.

What's strange is that godotengine/godot-proposals#7974 mentions the exact opposite issue…

@rpahut
Copy link

rpahut commented Oct 7, 2023

The root one does resize. The sub viewports too do match the pixel resolution until scaled. It just does not make much sense to have viewport resolution be set from the logical dimensions, this sounds arbitrary more than anyhing.

What proposal 7974 seem to talk about is the lack of respect for the size override when it is set explicitly. This needs to be fixed for the 50% scale override to produce pixel-perfect output as being requested.

@Calinou
Copy link
Member

Calinou commented Oct 7, 2023

It just does not make much sense to have viewport resolution be set from the logical dimensions, this sounds arbitrary more than anyhing.

SubViewports aren't always used to render them directly to the screen. They can be used as textures in 3D scenes, or as temporary buffers for shaders (e.g. a shader that "digs" inside snow or creates water waves).

These should generally not resize with the viewport resolution to avoid performance issues or avoid breaking the expected art direction (for pixel art games).

@rpahut
Copy link

rpahut commented Oct 7, 2023

Not always, but when vport is placed into container, it is expected to render as many pixels as it covers in the parent viewport. It needs to have the controls to be configured otherwise, but it is weird that by default it renders pixel-to-pixel and then breaks whenever the game is scaled.

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

No branches or pull requests

4 participants