• Unity
  • How to batch in Combining Skins?

Thanks for any help :tear:

Related Discussions
...
  • Изменено

Could you please describe in more detail what you want to achieve, what your current setup is and where you are encountering problems?

Harald написал

Could you please describe in more detail what you want to achieve, what your current setup is and where you are encountering problems?

Combining Skins try as code:
repackedSkin.Clear();
repackedSkin.AddAttachments(customSkin);
repackedSkin = repackedSkin.GetRepackedSkin("repackedSkin", sourceMaterial, out runtimeMaterial, out runtimeAtlas);
skeleton.SetSkin(repackedSkin);
skeleton.SetToSetupPose();
skeletonGraphic.Update(0);
skeletonGraphic.OverrideTexture = runtimeAtlas;

A skeleton have a independent texture that cause a drawcall. So many Combining Skins make that performance degradation.
.

Do you mean that you are facing problems that the GetRepackedSkin calls are expensive? Or do you mean that you still have too many batches when each of your skeletons has a repacked single atlas texture?

12 дней спустя
Harald написал

Do you mean that you are facing problems that the GetRepackedSkin calls are expensive? Or do you mean that you still have too many batches when each of your skeletons has a repacked single atlas texture?

i mean secend point: too many drawcalls when each of your skeletons has a repacked single atlas texture


Harald написал

Do you mean that you are facing problems that the GetRepackedSkin calls are expensive? Or do you mean that you still have too many batches when each of your skeletons has a repacked single atlas texture?

i mean secend point: too many drawcalls when each of your skeletons has a repacked single atlas texture


Harald написал

Do you mean that you are facing problems that the GetRepackedSkin calls are expensive? Or do you mean that you still have too many batches when each of your skeletons has a repacked single atlas texture?

Thank you for any help :tear:

Sorry for the delay in getting back to you, Harald is currently on vacation and will get back to you when he returns.

Sorry for the late reply.

It is hard to recommend a general optimal grouping of attachments to atlas textures without additional info. Repacking may be beneficial in some cases, but if you have e.g. 100 characters that use the same two atlas textures, then repacking may end up requiring more draw calls (with 100 different textures) than having those 100 characters use the same two atlas textures.

Could you please describe your scenario or share some screenshots? Please describe approximately how many skeletons are visible at once, how many share the same atlas, how many equiment or customization items are available, how many are equipped at once, etc.

Also please note that when you get many draw calls at a single skeleton when using two atlas textures (before repacking), you may reduce the number of draw calls by grouping attachments to atlas textures differently, as described here:
spine-unity Runtime Documentation: Material Switching and Draw Calls

Harald написал

Sorry for the late reply.

It is hard to recommend a general optimal grouping of attachments to atlas textures without additional info. Repacking may be beneficial in some cases, but if you have e.g. 100 characters that use the same two atlas textures, then repacking may end up requiring more draw calls (with 100 different textures) than having those 100 characters use the same two atlas textures.

Could you please describe your scenario or share some screenshots? Please describe approximately how many skeletons are visible at once, how many share the same atlas, how many equiment or customization items are available, how many are equipped at once, etc.

Also please note that when you get many draw calls at a single skeleton when using two atlas textures (before repacking), you may reduce the number of draw calls by grouping attachments to atlas textures differently, as described here:
spine-unity Runtime Documentation: Material Switching and Draw Calls

Different characters use the same two atlas textures is a good proposals.
How to execute?One charater create one skin. My code is as:

           Skin repackedSkin   = new Skin("repackedSkin");
	repackedSkin.Clear();
	repackedSkin.AddAttachments(skeleton.Data.DefaultSkin);
	repackedSkin.AddAttachments(customSkin);
	repackedSkin = repackedSkin.GetRepackedSkin("repackedSkin", sourceMaterial, out runtimeMaterial, out 
	skeleton.SetSkin(repackedSkin);
5 дней спустя
Harald написал

The easiest way is to pack your atlas textures separately from skeleton export. Spine allows you to use the Texture Packer separately to pack pre-arranged folders to atlases, as described in the following postings:
Is there any way to reduce drawcalls?
how Export 1 atlas as jpg and 1 as png?

The forum post is how to pack a texture from a fold. But combining skin is repack a new texture. The old pack texture is useless......

No, it's not useless. The skeletons of your characters are made up of different images. You want them all to share the same texture atlas with the least amount of texture atlas pages. Instead of recombining the images of a single character at runtime, you combine all images of all characters into a single texture atlas offline. You end up with a single texture atlas shared across all your characters, which is exactly what Harri has proposed and which is likely to minimize your draw calls.

Mario написал

No, it's not useless. The skeletons of your characters are made up of different images. You want them all to share the same texture atlas with the least amount of texture atlas pages. Instead of recombining the images of a single character at runtime, you combine all images of all characters into a single texture atlas offline. You end up with a single texture atlas shared across all your characters, which is exactly what Harri has proposed and which is likely to minimize your draw calls.

The reason I combine skins is one attachment show one more picture.
I don't know any other way to perform this requirement.

Please illustrate what you want to do with images. I'm afraid I don't understand your last reply.

Mario написал

Please illustrate what you want to do with images. I'm afraid I don't understand your last reply.

the Spine Examples-Mix and Match Skins

Please note that the number of different skeletons, number of atlas pages per skeleton and the number of equipment items matters here. I doubt that you have exactly the same use case scenario like the Spine Examples/Other Examples/Mix and Match Skins example scene and have the same number of skeletons (a single one) and equimpent items.

In order to be able to help, we need to know your use case better. So I repeat the question:

Harald написал

Could you please describe your scenario or share some screenshots? Please describe approximately how many skeletons are visible at once, how many share the same atlas, how many equiment or customization items are available, how many are equipped at once, etc.

In general there are two ways to approach combining skins:
A) Not perform any runtime-repacking of skins, instead pre-packing atlas pages smartly (e.g. one shared atlas containing all common equipment items if possible, another shared atlas with most common character appearance skin images, and so on) so that few pages are active at once and shared across many skeletons. As described in my posting above which you incorrectly described as "useless".
B) Perform runtime repacking. If you have 100 skeletons visible at once where each will have a repacked skin, this will not be a good option.

7 дней спустя
Harald написал

Please note that the number of different skeletons, number of atlas pages per skeleton and the number of equipment items matters here. I doubt that you have exactly the same use case scenario like the Spine Examples/Other Examples/Mix and Match Skins example scene and have the same number of skeletons (a single one) and equimpent items.

In order to be able to help, we need to know your use case better. So I repeat the question:

Harald написал

Could you please describe your scenario or share some screenshots? Please describe approximately how many skeletons are visible at once, how many share the same atlas, how many equiment or customization items are available, how many are equipped at once, etc.

In general there are two ways to approach combining skins:
A) Not perform any runtime-repacking of skins, instead pre-packing atlas pages smartly (e.g. one shared atlas containing all common equipment items if possible, another shared atlas with most common character appearance skin images, and so on) so that few pages are active at once and shared across many skeletons. As described in my posting above which you incorrectly described as "useless".
B) Perform runtime repacking. If you have 100 skeletons visible at once where each will have a repacked skin, this will not be a good option.

Perform runtime repacking make the workload of artwork is easier. So other way is "useless".

You can either have performance through shared atlases or "an easier artwork workload". This are hard technical limitations that we can not fix. You'll have to choose which option you want.

Mario написал

You can either have performance through shared atlases or "an easier artwork workload". This are hard technical limitations that we can not fix. You'll have to choose which option you want.

Thank you for your help 🙁