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

Contents of 3D SubViewport now look blurry #66764

Closed
lonevox opened this issue Oct 2, 2022 · 4 comments
Closed

Contents of 3D SubViewport now look blurry #66764

lonevox opened this issue Oct 2, 2022 · 4 comments

Comments

@lonevox
Copy link

lonevox commented Oct 2, 2022

Godot version

4.0 beta 2

System information

W10

Issue description

If you have a low resolution Viewport of a 3D scene in 3.5 it looks pixelated, which could be a desired effect like in my project.

3.5:
image

4.0 beta 2:
image

This unfortunately seems to be a regression in Godot 4. This might be because of the new SubViewport Scaling 3D feature which can't be found with the old Viewport. Scaling 3D has no option for nearest-neighbor scaling as seen here:
image
This might not be the reason, I'm just guessing.

Steps to reproduce

Create a SubViewport containing a 3D scene and zoom in on it in the editor. It will look blurred.

Minimal reproduction project

SubViewportScaling3.5.zip
SubViewportScaling4.0beta2.zip

@clayjohn
Copy link
Member

clayjohn commented Oct 2, 2022

What is the texture filter mode set to on the Canvas item using the ViewportTexture? It looks like your CanvasItem is set to use linear filtering (the default) instead of nearest filtering.

Note in 4.0 the texture filter mode is set on the CanvasItem not on the texture itself

@Calinou
Copy link
Member

Calinou commented Oct 2, 2022

This is not a bug – see @clayjohn's comment above. You can change the default texture filter in the Project Settings (make sure the Advanced toggle is enabled):

image

You can also set this on the SubViewportContainer to avoid affecting all 2D textures:

image

See also #60150, #52332 and #57679.

This unfortunately seems to be a regression in Godot 4. This might be because of the new SubViewport Scaling 3D feature which can't be found with the old Viewport. Scaling 3D has no option for nearest-neighbor scaling as seen here:

This is unrelated. 3D scaling only has an impact if the resolution scale is set below 1.0, and it never affects 2D rendering. There are plans to implement a nearest-neighbor scaling option, but not for 4.0 unless a motivated contributor steps up to do the required work.

@Calinou Calinou closed this as not planned Won't fix, can't repro, duplicate, stale Oct 2, 2022
@lonevox
Copy link
Author

lonevox commented Oct 3, 2022

Ah apologies. I knew of the texture_filter property but didn't realize it applied to viewports too, but that makes sense. Hopefully this at least helps someone else out if they encounter this when porting.

@prominentdetail
Copy link
Contributor

prominentdetail commented Dec 3, 2022

How do we apply this to a ViewportTexture that is used in a shader? I can't seem to disable the anti-aliasing.

edit: figured it out..

	vec2 screenSize = vec2(textureSize(subView, 0));
	
	ivec2 uvPixel = ivec2( int(UV.x*screenSize.x), int(UV.y*screenSize.y) );
	vec4 c = texelFetch(subView, uvPixel, 0);

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