- 수정됨
Mix and Match. New Material = new batch
Hey.
I have checked mix and match scene example and your API. I have noticed that during assigning new texture to "Original Spineboy", your api is creating new material. In result each time when I am creating copy of "Equpped Spineboy" I am adding new draw call. I mean, i understand that when creating first character with glasses would result in new draw call (new atlas) but creating copies of the same character with glasses should not. Is there any chance that this additional draw call could be reduced?
If you want them to share the material, don't do the repack operation for each instance. Do it once, and let all instances share the resulting repacked skin. That will let them share the Material, and preserve Unity's dynamic batching.
Just covering our bases, all Unity stuff:
Unity has a dynamic batching system, which can batch different Renderers using the same Material if they can be rendered in sequence (eg, when they are sorted next to each other).
When you add a different material, Unity can't dynamically batch it, so you have more draw calls.
If a single Renderer has multiple Materials, it inevitably needs multiple draw calls. One per Material.
Now Spine-Unity stuff:
Each renderable Attachment is linked to a Material. That's how the rendering system knows which texture and shader to use.
If all the Attachments use the same Material, it will allow the SkeletonRenderer/SkeletonAnimation to just use one Material.
The repacking API sampled in the Mix and Match allows you to repack the backing textures into a new Texture, and allows you to create a new Material.
It also creates copies of all the original Attachments but links them to that newly created shared Material.
All the new Attachments that are linked to the new Material are stuffed in a new "Repacked Skin". (a Spine Skin is basically a container for Attachments).
So if you use that Repacked Skin for any other skeleton instances of your character, they'll share that skin, and its backing texture and material. Batching is preserved.