Home --> Programming Projects --> Block Engine --> Meshes
The point if this section is to argue that based on some of the current limitations of OpenGL, the best way to render a block world is with a shader. That is, there are several limitations that together from a perfect storm of not being able to render block worlds efficiently without using a shader.

Limitation 1: No Texture Wrapping in a Texture Atlas

A texture atlas a very useful because it allows us to have all our block textures be subrectangles of one big texture. Once we have created this texture atlas, there is no need to swap textures when rendering. When using a texture atlas, the texture coordinates we use for our verticies will be within the subrectangle that corresponds to the block texture we want.

Texture wrapping refers to when a texture coordinate t (which is a float) is converted to a float between 0.0 and 1.0 (by wrapping). There are various situations in which we would like to use texture wrapping.

Suppose that we are using a texture atlas and we also want to use texture wrapping. Let's say the block texture we want to use is occupying the subrectanble (min_u, min_v, max_u, max_v) of our texture atlas. Given a texture coordinate pair (u,v), one would think there would be a way to tell OpenGL to wrap the coordinates inside the subrectanble (so that u is between min_u and max_u and v is between min_v and max_v). However, this feature seems to be missing from the current version of OpenGL. If we want to accomplish this, we must use a shader.

Limitation 2: Tex Coords Bound to Verticies in VBOs

It would be ideal if we could use three buffers:
(1) A buffer of (x,y,z) verticies;
(2) A buffer of (u,v) texture coordinates;
(3) A buffer of indicies (v_index, t_index) into the vertex and texture coordinate buffers.

The elements of the third buffer, the index buffer would come in groups of 3 to describe triangles.

Unfortunately, OpenGL does not allow us to do this. To my knowledge, OpenGL only allows our index buffer to contain indicies for a single buffer. Furthermore, each tripple of vertex coordinates (x,y,z) has to be right next to a pair of texture coordinates (u,v). This is unfortunate, because each vertex of our block world will have multiple texture coordinates associated with it, forcing us to duplicate vertex information.


Because of these two limitations, it appears as through we cannot render block worlds in OpenGL anywhere close to optimally without writing a shader to handle texture coordinates correctly.