Batch Rendering
Batch rendering is a rendering technique that most commonly describes a way to keep the number of draw calls issued per frame low by batching the relevant geometry beforehand.
Batch rendering with multiple textures
Ways to use multiple textures with batch rendering in OpenGL:
- Merge all textures on disk into one image offline and bind & use it
- Build a texture atlas at runtime when loading in all spritesheets and use it
- Use texture arrays (
sampler2DArray
). Textures need to be same size or resized. - Array of textures (
sampler2D tex_units[]
) inside fragment shader.- Bind textures as texture units and look up with index from VBO in a switch
- Indexing directly into array using a uniform is undefined behaviour