Hello,
I tried to use atlases to import my images, and I have encountered what looks like two bugs, and several questions.
To summarize quickly the problems:
- texture.GetData() does not return the same result when the image come from the atlas
- Creating an image with "SetSizeOverride" with a texture from an atlas with mipmaps fails when zooming out.
- observed in Godot 3.5 and 3.5.1
Problem 1:
texture.GetData() does not return the same data when the image is loaded from an atlas or directly. It seems that the data I get from the atlas are cropped.
Example:
On this images: 
Texture.GetData().GetHeight() returns:
- 64 when loading the texture with no atlas
- 47 when the texture is part of an atlas.
Likeliwe, texture.GetData().GetUsedRect() is ((0, 0), (50, 47)) on the atlas texture, and ((7, 9), (50, 47)) on the 'normal' texture.
It is an issue because I sometimes used texture.GetData().GetUsedRect() to detect the bounding box of the image and position it correctly inside a box; this fails when the texture comes from an atlas.
Questions: is this a known bug? How can I get the 'correct' (ie non cropped) rectangle GetUsedRect()?
Problem 2:
On some sprites I used a size override on the texture (see code below). However, when the texture is coming from an atlas, the sprite disappears when I zoom out.
This problem appears only when the texture comes from the atlas, with a size override, and with "flags/mipmaps=true" on the atlas.
Question: Are atlases fully compatible with mipmaps?
(Here the workaround is obviously to use sprite.Scale instead.)
static ImageTexture OverrideSize(Texture texture, float x, float y)
{
var imagetexture = new ImageTexture();
imagetexture.CreateFromImage(texture.GetData()); // Note ntaht the sprite is displayed at the same position with or without the atlas
var newsize = new Vector2(x, y);
imagetexture.SetSizeOverride(newsize);
return imagetexture;
}
And a few more questions:
- I have many images where most of the picture is made of only transparent pixels, except in a rather small box. These images could of course be cropped, but then fixing their position would be painful. Is there a significant performance cost in keeping these uncropped images ? Or is godot able to optimize this?
- What is the best practice with grouping images in atlases? What kind of improvement should I expect?