Atlas is not packing as expected (SOLVED)

When packing an atlas I want to keep the atlas as small as possible, within the power of two and the width and hight should keep as close to each other as possible. This to eliminate wasted texture space and memory when using a compression method that requires a square image.

The result right now is this 1024x128:

The expected result would be more towards this direction 512x256:

2 Likes

Thanks for the report!

I have the same problem in Defold 1.2.101.
Margin, padding && borders = 0
I know, that images can be packed inside 2048x2048. But Defold makes 4096x1024 :frowning:

3 Likes

It is a very irritating problems and hopefully they will add an algorithm that packs the images in an as square format as possible.

As you may have noticed you can probably fiddle around with the properties on the atlas to get it to pack better. Not the best work around but still a work around. I have also noticed that sometimes how the atlas is packed can change depending in which order you add the images to the atlas.

1 Like

I think, one of the simplest way to solve the problem adding support of texturepacker atlas formats or other custom extenrnal format.
For now *.atlas file just a list with images. If it would be something like:

{
	"filename": "arrow.png",
	"frame": {"x":868,"y":231,"w":33,"h":32},
	"rotated": false,
	"trimmed": false,
	"spriteSourceSize": {"x":0,"y":0,"w":33,"h":32},
	"sourceSize": {"w":33,"h":32}
},
{
	"filename": "blue.png",
	"frame": {"x":834,"y":942,"w":116,"h":71},
	"rotated": false,
	"trimmed": false,
	"spriteSourceSize": {"x":0,"y":0,"w":116,"h":71},
	"sourceSize": {"w":116,"h":71}
},

would be great.

Texture packer support many features and user can made any custom format https://www.codeandweb.com/texturepacker/documentation#custom-exporter-template-file-data-types

3 Likes

Does anyone have a reliable list of max texture sizes for different GPUs? This is what I remember:

2048x2048
iPhone 3GS
iPhone 4
iPad

4096x4096
iPhone 4s
iPhone 5
iPhone 6+
iPhone 6s
iPad 2
iPad 3
iPad Mini
iPad Air
iPad Pro

For Android it seems to be a really mixed bag of 2048x2048 for older or low-end devices and 4096x4096 for newer devices.

1 Like

Only place I have seen this information collected is on gfxbench.com, but unfortunately not in a list form. It is listed under each phone so only useful if you are curious about one particular device.

2 Likes

Would you be able to share this set of images with me? I’m experimenting with a fix for this, but it’s hard to get the texture packer to generate these really rectangular atlases.

Never mind. Managed to create one myself after a couple of tries.

1 Like

Hmm, I make few tests and I’m really confused:

Source: 40 images of different sizes and three atlases:

  1. “4x2.atlas”: 4096x2048 - default atlas builded by defold (Create new atlas and add /images/*.png)
  2. “4x1.atlas”: 4096x1024 - manually change file order inside atlas using text editor
  3. “2x2.atlas”: 2048x2048 - one of thousands randomly sorted versions of “4x2.atlas” by script



Thanks. I’m working on an improvement to our atlas/texture packer that will solve the problems you’ve mentioned above. This would be the output from your atlases:

7 Likes

Wow! Looking forward to it!

2 Likes

Fixes for atlas packing has been included in the release 1.2.103!

6 Likes

Thanks. Fixed for me:)

2 Likes

As I understand it was fixed only in editor1 ?

Yes, the fix will be ported to editor2 shortly!

2 Likes

This fix has now been ported to editor2 too and will be available in an update “within the hour”.

6 Likes