utkiupe

Hi guys,
So I have a spine asset with a lot of images. I had limited my atlas size to 2048x2048. The result is that I have 2 atlases for this asset.
When I inspect the object during the runtime, I notice that the materials get referenced between 10 to 13 times (the last 2 parameters appearing and disapearing constantly !) while I should have only 2 materials ( named Element0 and Element1 I guess).

It seems that one loop animation has its images split between the 2 atlases. Maybe it can be a cause...

When I try with only 1 atlas (by setting the size to 4096x4096), everything is ok. I only have one material referenced in Element0.
I will probably let as is now, since I guess that on the targeted plateforms (TVo and iOS) I can use 4096 atlases.

However, I am curious. Is there something wrong here ? Something I am not doing right ?

Thanks
Аватара пользователя
utkiupe
  • Сообщения: 39

Pharan

The material array doesn't reflect the number of materials you're using.
It reflects the number of times the renderer has to switch between materials to render the next thing.

So if, for example, you're rendering 5 images (a, b, c, d, e) from 2 different textures.
And a, b, c comes from material1, and d and e comes from material2.

If you have to render the parts in this order : a, e, b, c, d.
Then you'll have an array: material1(a), material2(e), material1(bc), material2(d).

And if you render in this order : d, e, a, b, c.
You'll have an array: material2(de), material1(abc).

If you open the dragon example scene, you'll see the same thing.

So as much as possible, you have to either group things coming from the same texture as much as you can, or make the images you need fit in one texture.
Аватара пользователя
Pharan
  • Сообщения: 5366

utkiupe

Oh ! Thank you very much !
The main issue remais in the fact that I can't have control on how the images are packed inside the atlases.
I can maybe try to use an external atlas packer (such as texture packer) to gain more control. Do you know if it's possible with the Unity runtime ?
Аватара пользователя
utkiupe
  • Сообщения: 39

Pharan

TexturePacker Pro works. It's a paid program though. But if you already have it, you might as well use it.
Spine packs a LibGDX atlas. Choose that data format in TexturePacker if you're using that.
If you're using meshes, make sure to set Trim Mode to None. This is equivalent to whitespace stripping in Spine's packer.

Spine also comes bundled with libGDX's packer so there's no real "need" to buy TexturePacker Pro. You can access the really barebones menu under Spine>Texture Packer....
But it's a difficult to control (you have to move images in their own folders and stuff, you have to manually pick folders every time, there's no live preview).
Аватара пользователя
Pharan
  • Сообщения: 5366

Mitch

You also have the choice to pack multiple atlases. Spine Unity in particular has the unique ability to use more than 1 atlas per skeleton.

https://www.youtube.com/watch?v=Im0RB6musvA

Not precisely what you need - but it explains using multiple atlases.
Аватара пользователя
Mitch

Mitch
  • Сообщения: 975

Pharan

Damnit, Mitch. Read OP post. :D
Аватара пользователя
Pharan
  • Сообщения: 5366

Mitch

Pharan писал(а):Damnit, Mitch. Read OP post. :D
I did. His problem could be solved by organizing his atlases so the parts aren't interleaved as badly. The issue is that TexturePacker doesn't pack with any knowledge of draw order. If he packs the lowest draw order stuff first, then the higher then it'll reduce drawcalls dramatically unless he's animating draw order a lot.

Ass.
Аватара пользователя
Mitch

Mitch
  • Сообщения: 975

utkiupe

thank you guys!
Actually on my previous projects I was working on starling and was using texturePacker pro, that I bought because I also had other spritesheets to pack (UI, etc.) I can manually choose how to arrange my spritesheets with it.
Аватара пользователя
utkiupe
  • Сообщения: 39


Вернуться в Unity