1

I'm developping a 3D application using OpenGL.

I have a misconception about a part of the following post: OpenGL VAO best practices

I'm not sure about the meaning of the term 'batch' in this post.

Does it means for each object of the scene ? So does it suggest to create a VAO for each object of the scene or several objects ? Does a batch refers to several objects sharing the same materials, transformations and shading ?

Community
  • 1
  • 1
user1364743
  • 5,283
  • 6
  • 51
  • 90

1 Answers1

2

A batch is simply a, well, "batch" (=bunch) of primitives, i.e. points, lines or triangles drawn by making a single glDraw… call. There's no deeper maging behind this.

Does it means for each object of the scene?

No. OpenGL doesn't know what a "model" is. This concept goes totally beyond what OpenGL does. OpenGL merely draws points, lines or triangles to the screen, and that's it.

So does it suggest to create a VAO for each object of the scene or several objects?

No, it suggests that you create VAOs and VBOs in such a way, that you can coalesce the maximum number of primitives (= triangle | line | point) that can be drawn with a minimum number of glDraw… calls into a single VAO/VBO.

For example say you'd render a warehouse full of cardboard boxes, where each box has a (slightly) different shape (think of the self service section in an IKEA store; I'm pretty sure those look about the same in every store around the world): Despite being of different shape the boxes have a lot in common: Their color, the texture, etc. So what you would do is put all those boxes into a single VAO/VBO and draw them all together using the same texture and shader through a single, or a handfull of glDraw… calls.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • Ok so to sum up what you said a batch is defined by all the geometry (meshes) in the scene sharing same texture (materials), transformation and shading informations. So if my scene is composed of a house with a specific texture and one hundred of trees around it with another texture but with a different shading there will be 2 batches. Is it true ? – user1364743 May 23 '14 at 10:40
  • 3
    @user1364743: No a batch is not defined in that particular way. A batch is simply all the geometry drawn by a single call `glDraw…`. Don't overthink it. There's no geometrical or scene related definition to it. A batch is anything that goes into a set that gets processed by a particular call to `glDraw…` and that's it. What you aim for is collecting data into such batches in a way, that you minimize the number of `glDraw…` calls. – datenwolf May 23 '14 at 10:51
  • Ok. Thank you for all your responses. – user1364743 May 23 '14 at 10:54