Texture slicing

Godot Version

4.3-stable

Question

I have a small problem. When I use smooth camera zoom using lerp(), all textures in the viewport are cut into squares for some reason.

In the project settings, I only changed the size of the viewport (800 by 450), set the mode to viewport and set the ratio to keep

demo

That is expected with your setup. You can call them pixels, some will call them texels.

You can solve in a few ways. But leaving as is a retro style.

One, Use a high resolution window. And then setup a low pixel viewport. Then the external camera can zoom in on the viewport and the pixels should be more stable. Another variation is you scale all your sprites to the high resolution.

Two, interpolate the camera by whole physical pixel numbers, based on the physical display resolution. This will be a little jittery but keeping a pixel within an whole number of physical pixels will produce a stable image.

2 Likes

Okay, so if I were to use the first option, I would need to configure a viewport node and attach the camera to the parent node. Would that cause it to zoom in correctly?"

Well, I tried the first method, but for some reason it didn’t help me. Could you visually show how the nodes should be arranged in the tree and what settings they should have, please?

I dont have the time to make a proto project. And many have already answered this question before.

The basic idea is there is a master viewport that is configured in the project settings. This should be set to a high resolution.

In your scene you need a subviewport container a subviewport. This is set to a low resolution and scaled to fit your high resolution window. Your zoom effect needs to take place outside of the subviewport.

Here is something close-ish to the concept at hand.

1 Like

Okay, I try this. At all thanks!