I would like to ask what is the background of sorting images in the atlas viewer and why it is commonly leaving a lot of space in a rectangle unused, making an impression like everything is trying to be above the diagonal? Is it for purpose? Could it be different - more “filling”? I think, I can’t explain it better, but I hope you’ll get a point
GPUs work more efficiently with textures that have power of two dimensions (512,1024,2048,4096,etc.), so Defold will try to arrange images in an atlas so that it fits in a rectangle with power of two dimensions.
Say you have a completely filled atlas. You add one more image. Defold finds out that it cannot rearrange all the images to make your new one fit, so it increases the size of the atlas. Being power of two dimensions, the next size will be twice the area of the previous size, so your atlas will be just a little over 50% filled (which seems to also be the case of your example above).
Aaa, that explains a lot! Thanks! So, it is a good practice to try to fill the atlas, minimalizing the usage, right?
Yes. Adding an image to an atlas that is not yet full is zero-cost for both memory and bundle size.
Thanks for an explanation and a tip!
And, if you’re interested why the box is filled in a certain way, you can read Jukka Jylänki’s excellent paper on “bin packing” which it’s commonly referred to. I believe we use the Skyline Bottom Left version.