Hi there!

I tried looking for this question in the forums but I can't find the answer.

What are the benefits of exporting animation asset layers into a single PNG rather than multiple and vice versa for Unity?

I'm exporting as JSON Spine version 3.8.79.

  • 전체글: 18


General optimization rules apply - the fewer materials (different textures) are in use, the lower the number of necessary draw calls:

Please note that when attachment textures are interleaved in order, such as A B A B A, an additional draw call is necessary at each change (five draw calls in total in this example).
On the contrary, when all attachments are on the same texture (in the example above it would be A A A A A) it will result in a single draw call.
사용자 아바타

  • 전체글: 2075


Thanks for the reply Harald!

Ah ok, that's really useful to know.
So if I export, would it be more efficient to have more pages(ie pngs) for each animation? Since from my understanding it would reduce the number of draw calls for animations not using a particular item in a PNG.

For your second statement:
What do you mean when you say attachment textures? You mean the items/ie layers in a single PNG once you export?
And how could they be interleaved in order?

Is there a downside to having multiple PNGs?

Thanks :) so much.
  • 전체글: 18


It all depends on your setup. Generally its better to try and have everything in one texture if possible.

What Harold is saying is that if you have multiple pages, and your spine characters use textures from different textures but they are intertwined throughout the layers of the spine object, you'll generate more draw calls.

So an optimization in that scenerio would be, for characters base body having them draw from 1 texture

Then if they have an outfit layered only on top, draw from a seperate texture.

However optimizations like this only benefit you if you wanna create more then 1 character.

If you are creating more then 1 character then its possible you can fit many characters within 1 texture.

If your creating a mix/match character creator then its likely best to have all ur base pieces in 1 texture, and then outfits in another that are overlayed.

You can then chose to bake out each character in a unique texture, or bake out multiple in batches and have characters share from them using some sort of manager. (what ill likely be doing)
  • 전체글: 64


Thanks @Anisoft for answering! Very much appreciated!
maasha 작성:What do you mean when you say attachment textures? You mean the items/ie layers in a single PNG once you export?
And how could they be interleaved in order?
@maasha I'm sorry I somehow compacted it a bit too much. What I meant is the "texture that an attachment is in".

When your slots (with attachments) are ordered in a particular way from back to front, defining what must be on top, you dictate the required render order.

Let's say you have slots ordered as follows from back to front:
S1, S2, S3, S4, S5
Each of the slots has the following image attachment:
A1, A2, A3, A4, A5
Now imagine that the attachments are packed to atlas page textures as follows:
T1: A1, A3, A5
T2: A2, A4
Now the interleaved texture order example above becomes this:
T1, T2, T1, T2, T1
Now since every change in texture requires a new draw call to begin, you end up with 5 draw calls.
If the attachments were instead packed into a single atlas page texture:
T1: A1, A2, A3, A4, A5
This results it the following texture draw order:
T1, T1, T1, T1, T1
which requires no texture changes, and could be done in a single draw call.

So in short:
[*] As @Anisoft pointed out, it is beneficial to have few atlas textures.
[*] If you need multiple, since they don't all fit into one, then it's advisible to group them by draw order (to prevent interleaved attachments from other textures). E.g. this could be one texture with the "base" of a character, which is drawn in the back, and one texture with equipment, which is typically in front.
사용자 아바타

  • 전체글: 2075

다시 돌아감: Unity