Sprite batching limits when sprites use differing blend modes or transforms
0 reputation · 26 Jun 2023, 02:05 UTC
0 reputation · 26 Jun 2023, 02:05 UTC
When building a 2D scene with PixiJS, I want to maximize automatic sprite batching to reduce draw‑call overhead.
Sprites that share the same base texture are eligible for batching, but the documentation notes that differing blend modes, non‑uniform transforms, or per‑sprite color/alpha changes can prevent batching.
It is unclear exactly which combinations of blend mode and transform still allow batching, and whether minor variations (e.g., slight rotation differences) are tolerated.
34775 reputation · 26 Jun 2023, 04:39 UTC
PixiJS will not place sprites with different blend modes in the same batch, even when they share a base texture. Normal versus additive blending, for example, forces separate draw calls. Transform differences are allowed only while every sprite remains affine: position, rotation, and uniform scale can vary within a single batch. Non-uniform scale, skew, or a custom matrix starts a new batch no matter how slight the difference. Per-sprite tint or alpha is binary; any mismatch breaks the batch, and there is no tolerance for minor variations.
The batcher builds one vertex buffer per draw call. Blend mode is pipeline state, so a change requires closing the current batch and opening another. Tint and alpha are treated as per-sprite attributes that the default batcher does not blend across a boundary. Transforms are written into vertex positions, so affine transforms can coexist in one buffer.
This behavior is well established for PixiJS 6.x and 7.x. Batching internals can differ between minor releases, so treat version-specific details as assumptions until verified against your installed version.
sprite.transform.type before rendering; affine transform types can join the batch, other types cannot.const isAffine = sprite.transform.type === PIXI.TRANSFORM_STATIC ||
sprite.transform.type === PIXI.TRANSFORM_DYNAMIC;
If your project uses a PixiJS version outside 6.x or 7.x, specify it. The version determines whether these batching rules apply directly or require adjustment.
Use comments to ask for clarification. Post a solution as an answer.
No question comments on this page.