• Editor
  • Atlas order determination when using "packSource": "imagefolders"

Hi, couldn't find info anywhere and not sure how does this work, so asking.

If I use packing by folders, in my case in .json:
"packSource": "imagefolders",
I am not sure which texture will be the first atlas and which textures will be _2 and _3 etc.
How is the order of folders / atlases defined? And is it always deterministic?

Related Discussions
...

When packing "image folders" with multiple skeletons in your project, you will have an image folder for each skeleton Packing is done as if all the contents of all the image folders were first copied into the same folder. I believe it is an error for different image folders to have files with the same name.

You would need to use subfolders to have control over which images are packed into which atlas page. One way to do this is to use a subfolder that matches the skeleton name. The tree in the editor has a feature to hide the skeletonname/ prefix on all your attachments to reduce clutter.

Packing is deterministic -- when run multiple times on the same input, you'll get the same output. However, note that if you like which atlas page it was putting images without using subfolders to control it but you change/add/remove images, the results will likely be different.

I am uncertain if we understand each other, so I will explain in more detail. I am using one skeleton with multiple skins. To ensure I have one atlas per one skin, I created a subfolder for each skin and I select "pack image folders to single atlas", which corresponds to "packSource": "imagefolders" in .json config when using CLI.

And now when I am to change graphics, I get a different order of atlases. I would assume the atlases would be packed e.g. by alphabetical order of the subfolders, but it seems random for different sprite combinations - which is probably what you are talking about int the last paragraph. Would it be possible to be sure the order of folders / atlases is always the same? Or maybe this whole thing is a feature request to enable packing by skins?

Subfolders normally cause the images in them to be output to a separate atlas page. Make sure Combine subdirectories is unchecked and that you don't have a pack.json file in your images folder that specifies combineSubdirectories: true.

Are you saying that you do get your skin images from each subfolder on a separate atlas page, but the page number sometimes varies when you change/add/remove images? That is expected, as it wasn't a design goal for Spine's texture packing. It would be difficult or impossible to do reliably because when an image doesn't fit on existing pages a new page is added, which would increase the atlas page image file name numbers for subsequent atlas pages.

Why do you need this? Typically the file name of an atlas page image that a region ends up on is unimportant. If you need to know, you can programmatically get a region, get it's page, and look at the name.

Ok, so I think I can split it now to two things:

1) We found a solution, we don't need to rely on specific atlas texture / material and can do it dynamically.

2) The problem is not when adding image gaining new atlas page. The issue is that folders are taken in random or different orders. Steps to reproduce on our side:

  • export spine project on Windows machine
  • it creates the first page for the first folder, second page for the second folder - fine
  • git commit, push
  • git pull changes on macOS machine
  • re-export the same spine project on macOS machine
  • it creates the first page for second folder, second page for first folder - the order of atlases is swapped

The folders do not use any special naming.
I think simple alphabetical order should work, but also, as I said, we can work around without that. But still, it is strange behavior.

  • Nate оценил это.

Gotcha, thanks for the explanation. It looks like a bug, we'll get it fixed in v4.2!

Great, thanks for the info!