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

Vulkan: 3D viewport no longer uses nearest-neighbor filtering when Half Resolution is enabled, resulting in a loss of sharpness #45081

Closed
Calinou opened this issue Jan 10, 2021 · 3 comments · Fixed by #61725

Comments

@Calinou
Copy link
Member

Calinou commented Jan 10, 2021

Godot version: Git c3b23f0, but applies all the way back to the initial Vulkan renderer

OS/device including version: Fedora 33, GeForce GTX 1080

Issue description: Unlike Godot 3.x's GLES3 and GLES2 renderers, the Vulkan renderer uses linear filtering when Half Resolution is enabled in the 3D viewport's Perspective menu. However, with a resolution scale of 50%, you can use nearest-neighbor filtering to benefit from a sharper image with no performance cost – in fact, nearest-neighbor filtering can be minutely faster.

We should revert to the 3.x behavior, at least when an integer scaling factor is used (1/2, 1/3, 1/4, …).

I think that by default, the engine should use nearest-neighbor filtering when using an integer scale factor and linear filtering with fractional scale factors (or scale factors above 100%). A Viewport property could be added to toggle between "Automatic", "Always Linear" and "Always Nearest" filtering modes.

See https://tanalin.com/en/articles/integer-scaling/ for more information.

Steps to reproduce: In a 4.0 development build, enable Half Resolution in the 3D viewport's Perspective menu.

Minimal reproduction project: N/A

@KoBeWi
Copy link
Member

KoBeWi commented Jun 4, 2022

I added this line:

subviewport_container->set_texture_filter(shrink ? TEXTURE_FILTER_NEAREST : TEXTURE_FILTER_PARENT_NODE);

here:

void Node3DEditorViewport::_update_shrink() {
bool shrink = view_menu->get_popup()->is_item_checked(view_menu->get_popup()->get_item_index(VIEW_HALF_RESOLUTION));
subviewport_container->set_stretch_shrink(shrink ? 2 : 1);
}

Before this change:
godot windows tools 64_mnmgbadwZC
After this change:
godot windows tools 64_l9ykAvzgcP

Does this solve the issue? 🤔

@KoBeWi KoBeWi moved this to To Assess in 4.x Priority Issues Jun 4, 2022
@KoBeWi KoBeWi moved this from To Assess to In Progress in 4.x Priority Issues Jun 4, 2022
@Calinou
Copy link
Member Author

Calinou commented Jun 5, 2022

I added this line:
...
Does this solve the issue? 🤔

Looks like that fixes it 🙂

That said, it may be better to rework Half Resolution to set the Viewport's scaling_3d_scale instead of shrinking the viewport. This is only available in 4.0, not in 3.x. This doesn't support nearest-neighbor filtering yet, but this should be straightforward to add.

@KoBeWi
Copy link
Member

KoBeWi commented Jun 5, 2022

That said, it may be better to rework Half Resolution to set the Viewport's scaling_3d_scale instead of shrinking the viewport.

Open a new issue for this.

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

Successfully merging a pull request may close this issue.

2 participants