3D Graphics Batching
Asked Answered
P

2

6

A lot of sites/articles say 'batch! batch! batch!'. Can someone explain what 'batching' represents with respect to shaders?

Namely, does

  1. changing textures
  2. changing arbitrary shader variables

mean something can't be 'batched'?

Pate answered 11/11, 2010 at 3:9 Comment(0)
W
8

The easiest way to summarize it is to try to make as few API calls as you can to draw what you need to draw. Using vertex arrays or VBOs (not even optional in modern APIs), texture atlases and avoiding the need for state changes all contribute to that. It's really amazing how many triangles a modern GPU can draw in the time it takes you to turn around and set up the next drawing call.

Whinstone answered 11/11, 2010 at 4:22 Comment(3)
And applying that to your two points, changing things negates batching. Changing textures isn't usually too bad, if both textures as in VRAM, but changing shader variables constantly can get slow.Estellaestelle
Thanks. How do modern game engine handle transformation matrices when batching though (which changes per object)?Pate
transformation matrices will be set as shader constants when needed. That's not a big problem because a lot of the scene is usually the world. It's static and does not need a transformation. If it does: Do transform the data at load-time, before you load it into the vertex-buffer.Grouping

© 2022 - 2024 — McMap. All rights reserved.