• RuntimesUnity
  • Reducing Batches & Draw Calls (Multiple textures, materials)

I created an empty scene in Unity and added my Spine 2D character (SkeletonAniamtion). When I checked the Profiler, I noticed there were 30 batches. My character uses 3 materials and 3 textures, and I exported it using the Binary option (since I’m working with Adventure Creator in Unity).

I assumed that the Atlas exported alongside the textures and materials would help reduce draw calls. However, I’m wondering—does having multiple textures and materials negatively impact performance? Would it be better to use a separate Unity Sprite Atlas to combine all the Spine 2D textures instead?

Any advice on optimizing Spine 2D characters for better batching and performance would be greatly appreciated!

Thanks!

    Related Discussions
    ...

    To reduce draw calls and improve performance when using Spine 2D characters in Unity, it's important to minimize the number of materials and textures used. Having multiple textures and materials can indeed negatively impact performance because each material switch results in a new draw call. Here are some strategies to optimize your setup:

    1. Use a Single Atlas Texture: Try to pack all your character's attachments into a single atlas texture. This can be done using Spine's texture packer, which allows you to combine multiple images into one larger texture. This reduces the number of texture bindings and, consequently, the number of draw calls.

    2. Optimize Material Usage: Ensure that your character uses as few materials as possible. If your character requires different materials due to different shaders or blend modes, try to minimize these differences or group attachments that use the same material together in the draw order.

    3. Repacking at Runtime: Consider using runtime repacking to combine skins or attachments from multiple atlas textures into a single texture. This can be particularly useful if you have dynamic character customization.

    4. Unity Sprite Atlas: While using a Unity Sprite Atlas might seem like a good idea, it is generally better to manage atlases directly through Spine for characters, as this allows for more control over how textures are packed and used.

    5. Batching Considerations: Unity's batching systems can help reduce draw calls when the same texture is used across multiple instances. Ensure that your setup allows for batching by using shared materials and textures where possible.

    By following these strategies, you can reduce the number of draw calls and improve the performance of your Spine 2D characters in Unity.

    • A Nate le gusta esto.

    Is using Unity's Sprite Atlas just cumbersome to manage, or are there other issues? I found this page (https://esotericsoftware.com/spine-command-line-interface) but didn’t fully understand it. Also, I need to export Spine 2D in binary format to be compatible with Unity's plugin, Adventure Creator. I'm not sure if I can use the CLI for that.

      acai I assumed that the Atlas exported alongside the textures and materials would help reduce draw calls. However, I’m wondering—does having multiple textures and materials negatively impact performance? Would it be better to use a separate Unity Sprite Atlas to combine all the Spine 2D textures instead?

      Draw calls will be combined if they use the same texture, i.e. atlas page texture. Please check whether you can change your skeleton's atlas pack settings in the Spine Editor to export a single larger atlas texture instead of resulting in 3 separate atlas pages, e.g. by increasing the maximum width and height or using Polygons packing mode to pack attachments more tighly.

      Using Unity Sprite Atlas follows the same rules, draw calls can be batched if they use a single atlas page texture. So you should export the Spine atlas textures as desired in the first place, packing multiple complete atlas pages together via Unity's Sprite Atlas makes little sense.

      acai Also, I need to export Spine 2D in binary format to be compatible with Unity's plugin, Adventure Creator. I'm not sure if I can use the CLI for that.

      Skeletons should always be exported in binary format instead of .json format for production. This has nothing to do with the separate .atlas.txt atlas description file.

      Got it! I was hesitant to increase the max width and height because I thought larger textures might hurt performance. Thanks for clearing that up!