HTML and CSS Reference
Figure 9-4. OpenGL ES 2.0 pipeline
A way to exploit this functionality is to render all opaque geometry from front to back. This can be done by
measuring the distance from the camera to the geometry and sorting, based on the calculation. From there on, the
geometry is submitted according to that ordering, which will likely result in use of the Early Depth Test.
Although it's often useful to think of a geometry as a singular object with its own data, there is nothing preventing
multiple geometries from sharing the same underlying vertex buffer; in fact, this can drastically reduce the number
of calls to the underlying API. Packing multiple sets of geometry in the same vertex buffer, known as batching, is a
common technique for geometry that contains a small number of vertices, such as sprites.
Assume that a scene has 100 of the same sprite being displayed on-screen. To draw the sprites in the best way,
such that the vertex buffer is shared between all instances, will necessitate setting a uniform for the transformation
and a draw call for each instance, requiring a total of 200 calls. However, if batched together through a shared vertex
buffer, all the sprites can be sent to the GPU with a single draw call.
Batching goes hand in hand with another technique, texture sheeting (see Figure 9-5 ). In a texture sheet (also
called a sprite sheet or texture atlas), multiple smaller textures are combined into a single texture. The individual
sprites are displayed by setting texture coordinates that correspond to the position of the texture data within the larger
sheet. This allows a greater number of sprites to be rendered in a single call.