• Runtimes
  • Phaser webgl -> Batch draw calls when spine has multilpe textures?

I have a Spine animaton for the main character in the game. Here I am replacing attachments and their respective texture at runtime in order to let the user customise their character.

However when I replace the textures these attachments now have individual textures rather than all from a shared atlas. This causes the webgl renderer to have an additional draw call for each attachment.

Is there some way to instruct the spine webgl rendered to batch these draw calls as it would when its rendering from sprite atlas? The device I am rendering on supports multiple texture units and i see phaser in other scenarios batching draws for multiple texture units.

Or, would I have to re-pack all the users customised textures into the same texture atlas as animation originally was based on?

  • Davide님이 이에 답장했습니다.
    Related Discussions
    ...

    To batch draw calls effectively when using multiple textures in Spine with Phaser and WebGL, you would need to ensure that all the attachments are using textures from the same texture atlas. When you replace attachments and their textures at runtime, if they are not from a shared atlas, each texture change results in a separate draw call.

    To achieve batching similar to when using a sprite atlas, you would need to repack the customized textures into a single texture atlas. This can be done either at runtime or beforehand. By doing so, you can minimize the number of draw calls, as the WebGL renderer can batch draw calls when all the textures are from the same atlas.

    Phaser and WebGL can handle multiple texture units, but for optimal batching, having all textures in a single atlas is the most efficient approach. You might consider using a runtime solution to repack textures if customization is frequent and dynamic.

    kimdanielarthur

    I'm afraid that, for now, spine-webgl can only handle one texture per draw call.
    So yes, re-packing your customized textures is currently the only option.

      Davide ok thanks for quick reply! I’ll just draw the substitute texture to the atlas texture region

      • Davide 님이 이 게시물을 좋아합니다..

      Works well in Phaser using DynamicTexture and drawing substitute textures onto existing texture atlas.

      However a small,note is that the actual underlying WebGLTexture of GLTexture is private, and “tricked” me as I first went through hoops of recreating whole GLTexture each time i wanted to change atlas. This is expensive as DynamicTexture in Phaser has to be snapshot’ed into suitable bitmap source.

      Just changing the WebGLTexture directly to point to DynamicTexture naturally works better.

      Maybe some getter/setter for manipulating webgltexture directly to make it more obviously available?