How do I scale UI textures to achieve a good dpi?

Godot Version


How do I scale UI textures to achieve a good dpi?

Image description: The upper element is a button icon 32x32, and below a sprite with 512x512 size scale down aproximately to the first.

If I try to insert a 512x512 image inside a button I’m unable to resize with transform. Is there a way to solve it?

There is a way to define a size override for any Texture2D (without resizing the data itself), but it’s not currently exposed to the scripting API.

My recommendation for now is to design your UI for a high base window size (like 3840x2160 for desktop games) and use the canvas_items stretch mode. Godot will downscale 2D rendering at window sizes lower than the base window size. Make sure to enable mipmaps on import on all textures to prevent them from looking grainy at low resolutions.

See the documentation on this subject: Multiple resolutions — Godot Engine (stable) documentation in English

Thanks for replying! Is there an issue or pr on github? Would love to keep track of this feature progress.

See discussion here: Move away from texture-size based sizes of components and icons in default controls · godotengine/godot-proposals · Discussion #9080 · GitHub