Help with pixel deforming when changing scale

4.5.1 stable

Question

Hi! I’m having a problem when animating my TextureButtons.

This is my button with its normal size. I’m using a Tween to animate it when hovering on the button.

This is the code:

create_tween().tween_property(button, “scale”, hover_scale, 0.1).set_trans(Tween.TRANS_SINE)

When i hover my mouse i change the scale to 1.1 both x and y and the pixel art on my button deforms like this:

If I change mannually the scale in the editor, it works perfectly. The problem comes when i do in in game. My buttons are inside a VBoxContainer, but i tested with a button without any Control parent and i have the same issue.

I have the “Default Texture Filter” to Nearest and my “Window Stretch” is on canvas_items and “Aspect” Keep.

I’m sure i’m not the first one who encountered this problem, but i didn’t finde anything related to this.

Elaborate please, what do you consider a perfect 10% scale for pixels?

When i change the scale parameter in the Godot Editor, the pixel art just looks bigger but keeps the same proportions–like when you scale an image in a text editor. The image looks the same, just larger.

However, when I scale it via code in-game, the pixels look out of place like here

image

In the first one the mice ears are inside the yellow box, but in the scaled one the ears are outside.

I dont understand why in the Editor it works great, but in-game the pixels sclae weirdly.

This is probably caused by the stretching mode you have configured for the game and the texture filtering you have set for the sprite. The game settings do not apply to the editor obviously.

If you have instructed the game to render at low resolution and to do no texture filtering, it would make the sprites to move and scale in visible increments. Then, if the sprite positions are not aligned to the game pixels, the increments for them would happen at different points. I doubt I can provide a comprehensible explanation really, you might want to just google and read on “pixel perfect in godot”.

Thank you so much!! :grin:

I looked and that was it.