0 votes

In other frameworks you add high density images and scale them down to be sharper. I was cheating and doing this with pixel art games. I'd add really high density art and then scale it down and use the filtering. This allowed me to have my pixel art game remain relatively sharp on different screen sizes. Can I do something similar in godot? I'm really struggling with scaling pixel art and preventing the artifacting stuff from happening.

asked Jan 25 in Engine by hamoom (35 points)

i mean i can zoom my camera way out to get the effect i want but now i need to scale all the units in the game too. I need to multiply velocity * 4 etc.. seems goofy. I just want to scale my original image down..

I created an issue for this:

https://github.com/godotengine/godot-proposals/issues/407

look at how I was able to accomplish pixel art with smooth scaling and camera movement using the technique outlined above. This was done in Corona SDK. i want to port this game to godot but I am running into a wall with the artwork scaling properly without distortion.

https://www.youtube.com/watch?v=HIARx0kW7XM

1 Answer

0 votes

One way I am investigating is, importing the texture as an image in the import box, so you can use the Image methods such as rezise () and then convert it to a texture image. I tried it and it works, but I don't know how the quality issue is, there are many options and interpolations and I know little and nothing about that. I keep investigating and I tell you.

extends Node2D
var img:Image
onready var tex= ImageTexture.new()
func _ready():
    img=preload("res://art/forest.jpg")
    img.resize(256,256,Image.INTERPOLATE_TRILINEAR)
    tex.create_from_image(img)
    var sp=Sprite.new()
    sp.centered=false
    sp.texture=tex
    add_child(sp)
    pass
answered Jan 26 by estebanmolca (1,201 points)

INTERPOLATE_LANCZOS I think, it is the highest quality interpolation. I reduced an image from 1920-1080 to 240-135 and it looks good to be an 8x reduction.Try it and tell me what you think and if the loss of quality is what you are looking for, ah I forgot that the mipmaps are but I know little about the subject, what Godot does is keep copies of the texture in different sizes and use the one that best adapt to the resolution and current size ... I am still investigating.
...Well, import a png 512x512 with the default options, I reduced the size by scaling the sprite, and the difference with activated mipmaps is notorious.

https://ibb.co/Lg2L75P
My conclusion: activate MipMaps, it adapts to different sizes and resolution, what to convert into image, scale and then convert to texture there is no notable difference

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.