Resizing sprite in viewport?

Godot Version

4.3

Question

How can I resize a Sprite2D in a viewport without the sprite being distorted?

Example

help2
On the left is a 2dSprite scaled to (2.4 by 2.4). On the right is the same sprite scaled to (2 by 2). For some reason scaling by any non whole number distorts the image.

Scene Tree

need_help
I am using a Sprite2D inside a SubViewport as the sprite of a Sprite3D. I am doing this because I need to use a clipping mask on the Sprite2D, and Sprite3D’s don’t have that functionality.

With nearest neighbor interpolation, scaling power of two numbers are quite simple, every pixel is turned into a larger square, anything else will have to fill some parts leaving oblong non-square pixels.

As an example I want you try manually resizing a image from 8x8 to 11x11. Maybe you can artistically decide on something that looks nice, but the computer is only doing math as fast as it can.

You could try Linear filtering but that’s the default so you may have already intentionally preferred Nearest.

I did set the 2dSprites texture filter to linear. Unfortunately that does fix the distortion, but severely blurs the image.
help_3

Sorry to say these are your two options as dictated by GPUs. It is a hardware issue, and GPUs just don’t know how you would like to scale pixel art by 2.4

  • scale by power of two
  • blurry

Dang well thank you anyway! Also would you happen to know why scaling works if I just was an png as the sprite for the 3dSprite? I’m just trying to figure out the logic so maybe I can find a work around?

In 3D it is actually scaling it to the viewport, like up to 1920x1080, or your screenshot is 887x328, just more pixels.

I see. Well thank you for all your help!