Cross-Texture Batching

Daniel Sperl
Allows batching of multiple textures in one draw call
style, batching


Per default, if objects in your scene use textures from multiple atlases, they will end up in separate draw calls. It's a huge challenge to optimize your scene in a way that keeps the number of draw calls as small as possible.

To overcome this limit, you can now use this extension. If you render your objects with this style, meshes with up to four different textures will be batched together. All that you have to do is make the MultiTextureStyle the default for all your meshes:

Mesh.defaultStyle = MultiTextureStyle;

That's it! (Ideally, you'd do this before starting Starling.)

Beware that this means that your fragment shaders will become much more complex than with the standard MeshStyle, so this is no silver bullet: you simply exchange load on the CPU with load on the GPU. But since many Starling apps are CPU bound, that's often just what you need.

Please note that this style is experimental. I've received reports that it causes problems on some hardware, etc. Nevertheless, it's a good example of the flexibility of Starling's new “MeshStyles”, and is great for experiments.

Context3D Profile

When you use this style, it's especially important that you start Starling with the “auto” profile selector, or force one of the “standard” profiles. That's because only beginning with the “standard” profile, Stage3D supports if-statements in the AGAL code, and those are used to simplify the complexity of the fragment shader. The extension will also work in all of the “baseline” profiles, but it's not as efficient.


  • 2016/04/01: First public version
  • 2016/04/04: Added support for “baseline” profile
  • 2016/04/12: Compatibility with latest Starling head revision

User Comments

Feel free to edit this part of the page if you want to add information that's lacking in the above description.
Questions are better asked in the forum, though.

  extensions/cross-texture-batching.txt · Last modified: 2016/04/12 14:28 by daniel
Powered by DokuWiki