안녕하세요

저는 초보개발자이며, 개발중인 게임에 다양한 스파인을 사용중입니다.

몬스터,플레이어캐릭터,아이템,스킬 까지 많은 부분을 사용중인데,
게임화면에 많게는 100개 이상의 스파인이 렌더링되기때문에
모바일환경에서 렉을 발생시킵니다.

문제를 해결하기 위해 구글에 검색을해서
스프라이트아틀라스 라는것을 알게되었는데
스파인 문서를 보면 스프라이트아틀라스에 관련된 설명이 나와있지만
제가 미숙해서 완벽히 이해할수가 없습니다.

제가 이해할만한 스프라이트아틀라스 관련 공식유튜브동영상같은게
존재하나요?

아니면 포럼에 글을 작성하는것 이외에는 다른 방법이 없습니까?

hello

I am a beginner developer, and I am using various spines for the game under development.

Monsters, player characters, items, and skills are used in many parts,
Because more than 100 spines are rendered on the game screen
It causes lag in mobile environment.

I searched on google to solve the problem.
I found out about sprite atlas.
If you look at the Spine documentation, there is an explanation related to the sprite atlas.
I'm inexperienced, so I can't fully understand.

Something like an official YouTube video related to Sprite Atlas that I can understand.
does it exist?

Or is there no other way other than posting on the forum?



Related Discussions
...

How to use sprite atlas
Should all spines be in one folder?

Or do I have to set up an export pack to use the sprite atlas and redo all the exports...?

스프라이트 아틀라스 사용법
모든 스파인이 하나의 폴더에 있어야 합니까?

아니면 스프라이트 아틀라스를 사용하고 모든 내보내기를 다시 실행하려면 내보내기 팩을 설정해야 합니까...?

Currently, the spine folder is divided like this.
현재 이런식으로 스파인폴더가 나눠져있습니다.

summary

This is an in-game play screenshot of a game in development.
Looking at the Stats, the number of Batches is over 100.
I wonder how to optimize objects that use the same spine!

요약

개발중인 게임의 인게임플레이 스크린샷입니다.
Stats를 보면 Batches수가 100개를 넘어가는데
같은 스파인을 사용하는 오브젝트들의 최적화 방법이 궁금합니다 !

이 문서 섹션 여기의 설명이 패킹 방법을 이해하는 데 도움이 되지 않았다는 뜻인가요? Spine 스켈레톤과 함께 사용할 Unity 내부의 Unity SpriteAtlas? Unity 내에서 아틀라스 텍스처를 패킹하는 것은 Spine을 사용하여(명령줄 인터페이스 또는 Spine 편집기 UI를 통해) 아틀라스 텍스처를 패킹하는 일반 Spine 워크플로를 사용할 수 없는 경우에만 권장됩니다.

여러 스켈레톤의 첨부 파일을 단일 아틀라스 페이지(및 단일 .atlas.txt 자산)로 압축하려면 다음 포럼 게시물에 설명된 대로 "폴더 구조별로 압축"해야 합니다.
https://zh.esotericsoftware.com/forum/d/16376-export-without-packing-images/3
그런 다음 여러 SkeletonDataAsset 애셋에서 동일한 _AtlasAsset.asset을 사용하여 여러 스켈레톤에서 동일한 아틀라스 텍스처를 재사용할 수 있습니다.

패킹할 때 하나 이상의 아틀라스 텍스처 페이지로 끝나지 않도록 하십시오. 그렇지 않으면(두 개의 텍스처가 있는 경우) 전체 목적이 무산되고 문제가 악화됩니다.

겹치는 스켈레톤의 깊이 순서는 불투명하지 않은(투명 대기열) 셰이더를 사용할 때 뒤에서 앞으로 그려야 하므로 일괄 처리 여부를 결정합니다. 따라서 두 개의 스켈레톤이 'A A B B' 순서로 겹치면 A 두 개와 B 두 개의 드로우 콜을 일괄 처리할 수 있지만(2 드로우 콜) 'A B A B' 순서에서는 아무 것도 일괄 처리할 수 없습니다(4 드로우 콜). 따라서 몇 개의 스켈레톤 유형이 장면에서 번갈아 가며 여러 번 겹칠 수 있는 경우 해당 텍스처를 단일 아틀라스 텍스처로 압축하는 것이 가장 좋습니다. 반면에 영웅은 한 번만 그려지므로 포장할 필요가 없습니다.


Do you mean that the explanation in this documentation section here did not help you understand how to pack a Unity SpriteAtlas inside Unity to be used with a Spine skeleton? Please note that packing atlas textures inside Unity is only recommended when you can't use the normal Spine workflow of packing atlas textures using Spine (via the command line interface or via the Spine Editor UI).

To pack attachments of multiple skeletons to a single atlas page (and a single .atlas.txt asset), you will need to "pack by folder structure", as described in the following forum posting:
https://zh.esotericsoftware.com/forum/d/16376-export-without-packing-images/3
You can then re-use the same atlas texture at multiple skeletons by using the same _AtlasAsset.asset at multiple SkeletonDataAsset assets.

Just be sure that when packing you never end up with more than one atlas texture page, otherwise (when having two textures) the whole purpose is defeated and matters are made worse.

Please also note that the depth order of overlapping skeletons determines whether they can be batched or not, since they must be drawn in back-to-front order when using a non-opaque (transparent queue) shader. So when two skeletons overlap in order A A B B, two A and two B draw calls could be batched (2 draw-calls) whereas in the order A B A B none can be batched (4 draw-calls). Thus it is recommended that wherever a few skeleton types can overlap in alternating order many times in your scene, it is most beneficial to pack their textures to a single atlas texture. Your hero on the other hand will be drawn only once and thus might not need to be packed.

    Do you mean that the explanation in this documentation section here did not help you understand how to pack a Unity SpriteAtlas inside Unity to be used with a Spine skeleton?

    이 문서 섹션 여기의 설명이 패킹 방법을 이해하는 데 도움이 되지 않았다는 뜻인가요?


    you're right.
    Even if I check the link, I'm not sure if it helps with the optimization I want.

    The confusing part after watching the related YouTube video is,
    When there are parts shared between spines
    Is Spine Atlas effective?


    In the image above, the skeleton soldier and human soldier's sword and shield share a spine.



    But if you look at the spines of the monsters I use,
    There is no part where the spine is shared between the 3 types of monsters.

    Let's take Unity's SpriteAtlas as an example.

    1.


    The gold chest object above has 4 placed in the scene, but the number of Batches is 2.

    2.

    This is the UI image.
    Skill icons are bound by sprite atlas,
    A total of 18 skill icons are placed in the scene,
    The number of Batches is 2 including the background.

    3.



    Finally, an animation using sprites.
    There are 4 objects, one with the same animation,
    The other one has two different animation objects, but
    Batches number is 2.
    In the same way, the image files were combined into a sprite atlas.

    Now, let's use Spine for this part.



    In the first screenshot, there are 3 different monsters, and the spines of the monsters are not shared...
    Even if there is no shared part of the spine
    (Like the sword and shield that share the spine of the skeleton soldier and the human soldier mentioned at the beginning)
    Using Unity's sprite atlas-like method
    Can you combine and optimize?

    Also, if you look at the 2nd and 3rd screenshots, there are monsters using the same spine.
    I placed 3 types in the scene, but unlike Unity's sprites, images, and animations, the number of Batches increases as much as the number placed. ( 6, not 4, including the background...)
    Is there any way to solve this part?

    P.S
    Because I still have very low knowledge on the optimization side
    Please forgive me if the quality of the question is poor T . T

    맞습니다.
    해당 링크를 확인해도 제가 원하는 최적화에 도움이 되는부분인지 잘 모르겠습니다.

    관련된 유튜브영상을 보고 헷갈리는 부분이,
    스파인끼리 서로 공유되는 부분이 있을때
    스파인아틀라스는 효과가 있는건가요 ?

    위의 이미지를 보면 해골병사와 인간병사의 검과 방패는 스파인을 공유합니다.

    하지만 제가 사용하는 몬스터의 스파인을 보면
    3종의 몬스터끼리 스파인이 공유되는 부분이 없습니다.

    유니티의 스프라이트아틀라스를 예시로 들어보겠습니다.

    위의 골드상자오브젝트는 4개가 씬에 배치되어있지만 Batches의 숫자는 2개입니다.

    이번엔 UI 이미지입니다.
    스킬아이콘들은 스프라이트아틀라스로 묶여있으며,
    총 18개의 스킬아이콘이 씬에 배치되어있지만,
    Batches 숫자는 배경을 포함하여 2 입니다 .

    마지막으로 스프라이트를 사용한 애니메이션입니다.
    하나는 동일한애니메이션을 가지고있는 4개의 오브젝트가 있고,
    다른 하나는 서로다른 애니메이션오브젝트가 2개있지만
    Batches 숫자는 2입니다.

    해당 부분또한 마찬가지로, 스프라이트아틀라스로 이미지파일들을 합쳐놓았습니다.
    이제 이부분을 스파인을 사용해보겠습니다.

    1번째스크린샷을 보면, 각기다른 3개의 몬스터가 있고 몬스터들의 스파인들은 공유되는 부분이없습니다...
    스파인이 공유되는 부분이없더라도
    (맨처음말했던 해골병사와 인간병사의 스파인이 공유되는 검과방패처럼)
    유니티의 스프라이트아틀라스같은 방식을 사용하여
    결합하여 최적화 할수있습니까 ?

    또한 2,3번째 스크린샷을 보면 동일한 스파인을 사용하는 몬스터가
    3종류를 씬에 배치했는데, 유니티의 스프라이트,이미지,애니메이션과달리 배치된 숫자만큼
    Batches의 숫자가 증가합니다. ( 배경을 포함하여 4가 아닌 6...)
    이부분을 해결할 방법이 있습니까?

    나는 아직 최적화쪽에 대한 지식이 매우 낮기 때문에
    질문의 수준이 좋지 않더라도 양해부탁드립니다 T.T

      Harald

      Please also note that the depth order of overlapping skeletons determines whether they can be batched or not, since they must be drawn in back-to-front order when using a non-opaque (transparent queue) shader. So when two skeletons overlap in order A A B B, two A and two B draw calls could be batched (2 draw-calls) whereas in the order A B A B none can be batched (4 draw-calls). Thus it is recommended that wherever a few skeleton types can overlap in alternating order many times in your scene, it is most beneficial to pack their textures to a single atlas texture. Your hero on the other hand will be drawn only once and thus might not need to be packed.

      ========

      As described above, binary + texture atlas: single atlas
      export
      Did I understand correctly?

      Even if you use a spine exported as a single atlas
      Draw calls still increase....

      Also, can you confirm what I wrote right above?
      Unable to tag by mistake

      위의 설명대로 한다면 바이너리 + 텍스처아틀라스 : 싱글아틀라스로
      내보내기
      제가 제대로 이해한게 맞습니까?

      싱글아틀라스로 내보내기한 스파인을 사용해도
      드로우콜은 여전히 증가합니다....

      또한 바로 위에 제가 적은 내용을 확인해주실수있습니까?
      실수로 태그를 하지 못했습니다 ....

        ant5033
        맞습니다.
        해당 링크를 확인해도 제가 원하는 최적화에 도움이 되는부분인지 잘 모르겠습니다.
        관련된 유튜브영상을 보고 헷갈리는 부분이,
        you're right.
        Even if I check the link, I'm not sure if it helps with the optimization I want.

        The confusing part after watching the related YouTube video is,

        언급된 섹션에 설명된 대로 Spine과 함께 Unity SpriteAtlas를 사용하는 것은 일반적인 워크플로가 아닙니다. 귀하의 경우에 사용하지 말아야 할 대체 방법입니다.

        이것이 표시되는 비디오를 언급했으므로: Spine 스켈레톤과 함께 사용하기 위해 Unity SpriteAtlas를 패키징하는 방법을 보여주는 비디오를 알지 못합니다. 아마도 혼동은 워크플로를 혼합하는 데서 비롯된 것일 수 있습니다. 이 설명서 섹션은 여기 사용 사례에 적합하지 않을 가능성이 높으므로 무시하는 것이 좋습니다. . 대신 Spine을 통해(명령줄 또는 Spine 편집기를 통해) 폴더 구조별로 아틀라스 페이지를 패킹하는 데 집중하는 것이 좋습니다.

        Please note that using a Unity SpriteAtlas with Spine as documented in the mentioned section is not a normal workflow. It is an alternative way which you likely should not use in your case.

        Since you mentioned a video where this is shown: I am not aware of a video that is showing how to pack a Unity SpriteAtlas for use with Spine skeletons. Perhaps the confusion comes from mixing up workflows. I would recommend to just ignore this documentation sections here since it's likely not for your use-case. Instead it would be better to focus on packing atlas pages by folder struction via Spine (via the command line or via the Spine Editor).



        ant5033
        스파인끼리 서로 공유되는 부분이 있을때
        스파인아틀라스는 효과가 있는건가요 ?
        When there are parts shared between spines
        Is Spine Atlas effective?

        여러 스켈레톤에 대한 공유 아틀라스 텍스처 및 재질을 사용하면 Unity의 일괄 처리 시스템이 각 메시를 일괄 처리할 수 있습니다. 아틀라스 텍스처나 재질이 다른 경우 일괄 처리할 수 없습니다. 따라서 가능하면 여러 스켈레톤에서 공유된 아틀라스 텍스처와 재질을 사용하는 것이 좋습니다.
        Having a shared atlas texture and material for multiple skeletons allows Unity's batching systems to batch the respective meshes. If you have different atlas textures or materials, it cannot be batched. So it is recommended to use a shared atlas texture and material at multiple skeletons where possible.



        ant5033
        여러 스켈레톤에 대한 공유 아틀라스 텍스처 및 재질을 사용하면 Unity의 일괄 처리 시스템이 각 메시를 일괄 처리할 수 있습니다. 아틀라스 텍스처나 재질이 다른 경우 일괄 처리할 수 없습니다. 따라서 가능하면 여러 스켈레톤에서 공유된 아틀라스 텍스처와 재질을 사용하는 것이 좋습니다.
        But if you look at the spines of the monsters I use,
        There is no part where the spine is shared between the 3 types of monsters.

        관련된 부분은 단일 스켈레톤 유형에서 오는 것이 아니라 출력 메시의 재질과 텍스처가 동일한지 여부입니다.
        The relevant part is whether the output mesh has the same material and texture, not whether it comes from a single skeleton type.



        ant5033
        그리고 2,3번째 스크린샷을 보시면 같은 척추를 사용하는 몬스터들이 있습니다.
        씬에 3가지 타입을 배치했는데 유니티의 스프라이트, 이미지, 애니메이션과 달리 갯수만큼
        배치 수가 증가합니다. (4가 아닌 6, 배경까지 포함해서...)
        이 부분을 해결할 방법이 없을까요?
        Also, if you look at the 2nd and 3rd screenshots, there are monsters using the same spine.
        I placed 3 types in the scene, but unlike Unity's sprites, images, and animations, the number of Batches increases as much as the number placed. ( 6, not 4, including the background...)
        Is there any way to solve this part?

        Unity에서 무언가를 일괄 처리하지 않는 이유를 말하기 어려운 경우가 있습니다. 다른 재료의 메쉬가 ABAB(4 배치)와 같은 방식으로 겹치면 AABB(2 배치)와 같이 배치할 수 없습니다. 따라서 그것들을 조금 더 멀리 이동하고 깊이(Z) 순서가 변경되는지 확인해야 할 수도 있습니다. 여기에 설명된 대로 일괄 처리에는 몇 가지 제한 사항이 있습니다. 정점 수가 너무 많을 수도 있습니다("Unity는 900개 이상의 정점 속성과 225개 이상의 정점을 포함하는 메시에 동적 배칭을 적용할 수 없습니다."). 일반 렌더 파이프라인 또는 URP를 사용하고 있습니까? URP를 사용하는 경우 일괄 처리 동작이 약간 다릅니다.

        It is sometimes hard to say why something is not batched by Unity. If the meshes of different materials overlap in a way that is like ABAB (4 batches), it cannot be batched like AABB (2 batches). So you might need to move them apart a bit more and check whether depth (Z) order changes anything. There are some limitations to batching, as documented here. It may also be that the vertex count is too high ("Unity can’t apply dynamic batching to meshes that contain more than 900 vertex attributes and 225 vertices."). Are you using normal render pipeline, or URP? If you are using URP, the batching behaviour is again a bit different.

          ant5033
          위의 설명대로 한다면 바이너리 + 텍스처아틀라스 : 싱글아틀라스로
          내보내기
          제가 제대로 이해한게 맞습니까?
          As described above, binary + texture atlas: single atlas
          export
          Did I understand correctly?

          Single Atlas vs Atlas per Skeleton 옵션은 프로젝트에 여러 골격이 있는 경우 수행할 작업을 결정합니다. 프로젝트 내의 여러 스켈레톤에 대해 단일 아틀라스를 패킹하지만 하나 또는 여러 텍스처에 맞느냐에 따라 여전히 여러 아틀라스 페이지 텍스처를 가질 수 있습니다.

          내보내기 전에 단일 프로젝트에 여러 스켈레톤을 추가했습니까? 내보낸 자산의 스크린샷을 공유해 주시겠습니까? 여러 골격에 대한 단일 아틀라스 페이지 텍스처입니까, 아니면 여러 개입니까?

          This Single Atlas vs Atlas per Skeleton option is deciding what to do to if you have multiple skeletons in the project. It will be packing a single atlas for multiple skeletons inside your project, however depending on if it fits onto one or multiple textures, it can still have multiple atlas page textures.

          Did you add multiple skeletons in the single project before export? Could you share a screenshot of your exported assets, is it a single atlas page texture for multiple skeletons, or multiple?

            Harald

            이런 초보적인 질문에도 상세하고 친절한 답변 감사드립니다 : )
            당신이 공유해준 링크와 상세한설명 덕분에 많은 부분이 이해가 갔습니다 !

            예를 들어 해골병사와 인간병사가 검과 방패를 공유하는것처럼 제 몬스터의 경우
            "A몬스터"와 "B몬스터"의 가면이 같다면, 가면의 atlas textures 와 materials을 공유하는게
            제 프로젝트의 성능최적화에 되겠군요.
            감사합니다.

            Thank you for your detailed and kind answers to such a rudimentary question 🙂
            Thanks to the links and detailed explanations you shared, a lot of it made sense !

            For example, a skeleton soldier and a human soldier
            For my monsters like sharing a sword and shield
            If the masks of "Monster A" and "Monster B" are the same, sharing the masks' atlas textures and materials will optimize the performance of my project.
            thank you

            도움이 되셨다니 다행입니다, 친절한 답변 감사합니다! 🙂
            Glad it helped, thanks for your kind reply! 🙂

            Harald

            For this part, if there is only one skeleton, use Single Atlas.
            If you have multiple skeletons, you can use Atlas per Skeleton
            is it right?

            For example, when I was working on an existing spine export,




            1. Open the monster 1 folder in the monster folder,
            2. After running Spine, export the project.

            method was used.

            however,
            Thanks to your answer, I know I can put my project together!

            Using Project Import (Skeleton)
            If there are multiple projects (multiple skeletons), use the Atlas per Skeleton option.

            Like the way I used to work, when exporting only one skeleton
            What you can do with the Single Atlas option
            Is that correct?

            If you check the result of exporting using the two methods,
            In the repetitive task of simply exporting one project at a time,

            It seems that you can quickly process repetitive work by exporting multiple projects at the same time,

            Are there any other differences that I'm not aware of?
            When I checked only the output of the export, there seemed to be no difference!

            이부분은 뼈대가 한개라면 Single Atlas를 사용하고,
            뼈대가 여러개인경우 Atlas per Skeleton를 사용하면
            되는게 맞습니까 ?

            예를들어 제가 기존에 스파인 내보내기를 작업할때는

            1. 몬스터폴더에서 몬스터1폴더를 열고,
            2. 스파인을 실행한뒤 해당 프로젝트를 내보내기.

            방식을 사용했습니다.

            그런데,
            나는 당신의 답변덕분에 프로젝트를 합칠수있다는걸 알게되었습니다!

            프로젝트 가져오기 (뼈대) 를 사용하여
            여러프로젝트(여러뼈대)가 존재할 경우에는 Atlas per Skeleton 옵션을 사용하고,

            기존에 내가 작업하던 방식처럼, 1개의 뼈대만 내보낼때에는
            Single Atlas 옵션을 사용하면되는게
            맞습니까?

            !

            두 방식을 사용하여 내보내기를 했을때의 결과물을 확인해보면,
            프로젝트 1개씩을 단순 내보내기 하는 반복작업에서,

            여러프로젝트를 동시에 내보내기하여 반복작업을 빠르게 처리할수있는거같습니다만,

            이외에 혹시 내가 모르는 차이점이 있습니까?
            내보내기의 결과물만 확인했을때는 차이점이 없어보였습니다 !

              ant5033
              이부분은 뼈대가 한개라면 Single Atlas를 사용하고,
              뼈대가 여러개인경우 Atlas per Skeleton를 사용하면
              되는게 맞습니까 ?
              For this part, if there is only one skeleton, use Single Atlas.
              If you have multiple skeletons, you can use Atlas per Skeleton
              is it right?

              예, 프로젝트에 스켈레톤이 하나만 있는 경우 항상 하나의 아틀라스만 내보냅니다. 스켈레톤이 여러 개인 경우 'Single Atlas'는 여러 스켈레톤의 부착물을 단일 아틀라스에 결합합니다.
              Yes, if you only have one skeleton in your project, it will always export only one atlas. If you have multiple skeletons, Single Atlas will combine attachments of multiple skeletons to a single atlas.

              이외에 혹시 내가 모르는 차이점이 있습니까?
              내보내기의 결과물만 확인했을때는 차이점이 없어보였습니다 !
              Are there any other differences that I'm not aware of?
              When I checked only the output of the export, there seemed to be no difference!

              'Atlas per Skeleton'으로 내보내면 동일한 결과가 나오며, 뼈대를 각각 별도로 내보내는 것과 차이가 없습니다.
              Exporting with Atlas per Skeleton will yield the same result, there is no difference to exporting the skeletons separately each.



              프로젝트 1개씩을 단순 내보내기 하는 반복작업에서,
              여러프로젝트를 동시에 내보내기하여 반복작업을 빠르게 처리할수있는거같습니다만,
              In the repetitive task of simply exporting one project at a time,
              It seems that you can quickly process repetitive work by exporting multiple projects at the same time,

              쉘 스크립트에서 뼈대를 한 번에 내보내려면 명령줄 인터페이스를 사용하여 내보내기를 자동화하는 것이 좋습니다. 이렇게 하면 반복적인 수동 내보내기를 피할 수 있습니다. 또한 향후 Spine 버전을 업그레이드해야 할 때(예: 4.1에서 4.2로) 쉽게 다시 내보낼 수 있습니다.

              또한 위의 게시물에서 언급했듯이 스켈레톤의 배치를 개선하기 위해 별도의 아틀라스로 모든 스켈레톤을 내보내는 대신(따라서 별도의 아틀라스 텍스처와 재료). 그런 다음 여러 개의 서로 다른 스켈레톤이 단일 텍스처 및 재질로 공통 아틀라스를 공유할 수 있습니다.

              이 포럼 게시물(위의 이전 게시물에서도 언급됨)에서 유용한 링크를 찾을 수 있습니다.
              https://zh.esotericsoftware.com/forum/d/16376-export-without-packing-images/2


              Please note that it is recommended to automate your export by using the Command Line Interface to export your skeletons from a shell script in one go. This will avoid the repetitive manual export. It also makes re-export easy when you should upgrade the Spine version in the future (from 4.1 to 4.2 for example).

              Also note that as mentioned in my postings above, to improve batching of skeletons, you could use a shared atlas (with a single atlas page texture) for multiple skeletons, instead of exporting every skeleton with a separate atlas (and thus separate atlas Texture and Material). Then multiple different skeletons could share a common atlas with a single texture and material.

              You can find useful links in this forum posting (mentioned in a previous posting above as well):
              https://zh.esotericsoftware.com/forum/d/16376-export-without-packing-images/2

                Harald

                thank you
                It helped a lot in development! 🙂

                감사합니다
                개발에 많은 도움이 되었습니다 ! 🙂

                도움이 되셨다니 다행입니다. 문의해 주셔서 감사합니다. 🙂
                Glad it helped, thanks for getting back to us! 🙂