• Editor
  • How to merge atlas

How much space is wasted depends greatly on the particular images and the many texture packing settings. If packing multiple skeletons together is more efficient use of space, doing it can save some memory at runtime. It also can reduce draw calls at runtime.

If your images are in different folders, I suggest writing a script to copy them to a common folder where they can be packed. See the combineSubdirectories setting so subfolders won't cause the images to be packed on different pages.

    Related Discussions
    ...
    6 днів пізніше

    Nate Hi, I exported spineBoy, and then merged the texture and atlas of spineBoy and raptor, but when I replaced the atlas and tex of spineBoy with the merged atlas and tex, an error occurred. Why is this?



    I want spineBoy and raptor to share the same atlas and texture
    When I merge two textures, how can I make them share the same pattern instead of having two heads and two mouths in one picture?

    I would need to see your atlas to be sure, but I assume it contains region names like:

    spineboy/crosshair
    spineboy/head
    raptor/head

    In the Spine projects, the attachments are named eg crosshair so that is the name it looks for in the atlas. It's not there because it's spineboy/crosshair.

    You can use combineSubdirectories to pack folders together and flattenPaths to remove the folder names. However, you need to take care if two folders contain an image with the same name, like head. When using flattenPaths usually you want all the image names to be unique.

    Alternatively, you can modify the Spine projects so they use attachment names like spineboy/head and raptor/head. You'd set all the projects to point at the same images folder, which also makes it easy for projects to share the same images. Then the atlas you've made will work. You can use the Find and Replace dialog to make adding these prefixes in the Spine editor easier.

    Alternatively, you can create your own AttachmentLoader at runtime that knows which skeleton it is loading. When loading the spineboy skeleton, it would look in the atlas with a spineboy/ prefix to the region name. When loading the raptor, it would use a raptor/ prefix. Then the atlas you've made will work.

    How attachment images are found in the atlas is very simple. It's similar to how it's done in the editor, see here:
    http://esotericsoftware.com/spine-images#Image-file-lookup
    At runtime, see here:
    http://esotericsoftware.com/spine-loading-skeleton-data
    AtlasAttachmentLoader is used by default and it looks in the atlas for the attachment name (or path). You can customize that, as mentioned above, by using your own AttachmentLoader. Otherwise, you need to make sure the paths in the atlas (look at it with a text editor) are the same as you see in the Spine editor relative to the images folder.

    If two images are 100% identical, they will only be packed in the atlas once if alias is enabled. That is one way to avoid having two of the same head images. If they differ at all, even a single pixel, they will be packed separately.

      Nate I first packaged spineBoy and raptor respectively and obtained their atlas and texture. Then I put their atlas and texture in the same folder, and then used "combineSubdirectories" to package them into new atlas and texture. What are the steps for this? Right?

      That won't work at all. Open your atlas with a text editor and look at the regions in it. You'll have 2 regions: one for spineboy and one for raptor.

      You can't pack two already packed atlases. You need to pack all the images into a single atlas. If you keep the images in different folders, you can copy the files into a temporary folder and pack them from there. You can write a script that does this to make it easier.

        Nate OK, I'll try. Thanks

        рік пізніше

        Nate Hi dudes
        excuse me I still do not know how to set public atlas, do we have some tutorials ?
        For exsample, I m going to make some trees and I have many tree stems and leaves tex, I hope that leaves tex will be set as a public atlas for all tree stems. So all of my trees can use the same leaves atlas

        Pack a single atlas containing all of your images for multiple skeletons.

          Nate I can pack many project at once ?

            suanLoBeach I'm afraid this question is a bit vague, so I'm not sure if this is the answer you're looking for. However, if you want to create texture packs for multiple Spine projects, you can do so using a script. The following export scripts may help:
            Blog: New export shell scripts

            That said, while I mentioned "at once," the packing itself is still done on a per-project basis. The script simply searches for the target Spine projects and packs each one it finds. In that sense, you cannot truly pack multiple projects simultaneously.

            Nonetheless, the script is quite useful, and we recommend it to all users. If you haven't tried it yet, I highly encourage you to give it a go.

              Misaki thanks lady.
              I don't wanna pack many project, I just want to let my trees use the same leaf atlas texture. but now every tree exported have themself 's leaf atlas. I want my trees use the same leaf texture. they only have different stems

              What I mean is that when I export the first tree, the texture contains the leaves, but when I export the second tree, the texture also has the leaves, but these leaves are the same, so the performance is wasted. What I want to ask now is how to make all trees use the same leaf texture

              Please read the documentation here:
              https://esotericsoftware.com/spine-texture-packer

              suanLoBeach I can pack many project at once ?

              There are 2 ways to pack, see the documentation above. Packing as part of data export is for convenience only. Otherwise you pack a folder containing images, not projects. So, pack a folder containing all your images. If you don't have such a folder, write a script that copies files around until you do. This is the same advice I gave you above.

                Nate I'm going to create a public spine project to pack public texture and export it as a public atlas texture, so is this way correctly ?

                I don't understand what you mean by "public"?

                You are asking if creating a Spine project and packing it is correct? That greatly depends on your goals.

                I suggest: Create as many projects as you want and export them as data, without packing an atlas. Collect all their images into one folder and run the texture packer to pack them all into one atlas.

                  Nate In this case, do I need to run the texture packer first? Then use the packed texture to make different spine characters?

                  What I actually want to know is how can I make one spine character use a part of the atlas texture of another spine character, for example, I want character 2 to use character 1's hat, but I don't want this hat to appear in character 2's atlas, because it wastes performance, and I want all hats to be rendered only once.

                  You should try achieving what you want and see how it goes. Doing that will answer most of your questions.

                  You never use an atlas in the Spine editor. Atlases are for runtime.

                  Images are found by name in the editor:
                  https://esotericsoftware.com/spine-images#Image-file-lookup

                  They are also found by name in an atlas at runtime. Multiple skeletons can use the same atlas, as long as it contains the regions (by name) that the skeleton needs.

                    Nate I now package the maps that need to be used in common into several shared textures, and then use them in different spine projects, but there is a question, can spine set different material slots? I want the same Spine Mecanim GameObject to have different material slots. I need to give a single spine character different materials.

                    Nate thank you for your reply and we can close the quastion or issue, I get the correctly mothed and I know I don't need the public texture 😅

                    • Nate вподобали це.