Cross-Texture Batching

author:
Daniel Sperl
description:
Allows batching of multiple textures in one draw call
compatible:
v2.0
tag:
style, batching
homepage:
https://gist.github.com/PrimaryFeather/94d8650c294406050d77cc901dfb2a64

Overview

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.

Changelog

  • 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