Viewport node 2d resolution?

Godot Version

4.4

Question

Is there a way to increase the resolution inside a viewPortContainer/viewPort in 2d ?
also the options MSAA 2D / Screen Space AA / Use TAA dont seem to take any effect nothing changes when i turn them on ?

Its impossible to draw levels like this ?
The player is inside a viewPort
the outside level resolution is much better than the one on the player… they dont match ?

I wanted to DE-crease the resolution of the level, and IN-crease the resolution of the player

1 Like

If I had to make a wild guess, I suppose you might have filters turned on for your sprites.

Go to Project Settings, and set: renderingtexturescanvas_texturesdefault_texture_filter to Nearest

Maybe something like this?

Background Viewport (Low Res) :

Set viewport.size = Vector2(320, 180) (or something low-res).

Set render_target_scale = 1.0.

Set render_target_v_flip = true.

In the ViewportContainer, scale it up to fill the screen. This creates that pixelated / blurry look.

Character Viewport (High Res)

Set viewport.size = full window size (e.g., 1280x720).

Place only the character and UI here.

Set render_target_v_flip = true.

Ive increased the player scale inside the viewport, and the resolution gets better… But the viewport resolution outside in project settings/window always seems to bypass the other viewport
My current resolution is 480x272 it only works in mode / canvas items, but the level outside seems to be more defined

I think it has something to do with camera zoom

What if you could dynamically adjust the resolution or scale of a Viewport in real-time, based on camera movement or zoom level. So you could adjust to the zoom and make it as sharp or blury as you wanted?

I have no idea this would work. But, what if Instead of relying only on ProjectSettings.display/window, explicitly set the Viewport’s size:

$PlayerViewport.size = get_viewport().size

Do this in _ready() or on window resize.

Now Let’s say you have a Viewport inside a ViewportContainer, and a Camera2D moving in and out.

Scene Setup

Main (Node2D)
├── Camera2D
├── ViewportContainer
│ └── Viewport (named PlayerViewport)
│ └── PlayerScene

Script on Your Main Node

@onready var player_viewport := $ViewportContainer/PlayerViewport
@onready var player_camera := $Camera2D

func _process(delta):
var zoom_level = player_camera.zoom.length()

# The more you zoom in, the higher the viewport resolution
var base_res = Vector2(480, 272)
var scaled_res = base_res * clamp(zoom_level, 0.5, 2.0)
player_viewport.size = scaled_res.floor()

This maybe should increases or decreases the resolution of the Viewport as the camera zooms in or out. When you zoom in (closer to subject), resolution increases = more sharpness. Zoom out = resolution drops = more blur.

Then for maybe a Smoother Transition

Instead of snapping, we interpolate smoothly:

var target_res = base_res * clamp(zoom_level, 0.5, 2.0)
player_viewport.size = player_viewport.size.lerp(target_res.floor(), 0.1)

I cant understand… nothing in the viewport seems to work, has you mention
when the viewport resizes the image inside doesnt resize with it, it gets cut

Using “size_2d_override_stretch” doesnt do anything ?
all other 2D options also dont seem to take any effect ?
“msaa_2d”
“screen_space_aa”
“use_taa”
“use_hdr_2d”

these options work in project settings/rendering/antialiasing ?

test project
use mouse wheel to zoom In out