Skip to main content
Batching

Batching

· 2 min read
Balaur

Nodes that draw alike now go to the GPU as one call, with a position, a size and a tint per instance. Nothing turns it on.

Sixteen sprites cut from one sheet, turned, scaled, tinted and flipped apart, drawn in a single call

What it costs, offscreen at 1600x1000

caserender CPU beforeafterGPU beforeafter
5000 circles22.7 ms0.41 ms1.56 ms1.02 ms
2000 cuboids30.7 ms0.77 ms3.67 ms4.03 ms
2000 balls31.9 ms1.49 ms13.5 ms5.50 ms

What joins a call

kindgrouped by
spritesimage, material
shapesprimitive and its size, material
meshesgeometry or mesh asset, texture, material, shadows, light layers
  • A sheet frame joins the run. The frame is a rectangle on the instance, where it used to be a private copy of the built-in quad with rewritten coordinates.
  • In two dimensions a run is cut along the draw order, so what covers what does not change. In three it is not, because geometry is depth-tested.

Eighteen cubes turned, scaled and tinted apart, lit and casting shadows, drawn in a single call

What keeps a draw of its own

kindwhy
polygon, polylinegeometry of its own
own materialits own pipeline
skinned, morpheddeformed on its node
cloner, levels of detailalready instanced, or swaps geometry
uneven scalethe instance's matrix goes through its normals