

In OpenGL, there are basically two ways to do this:

Where this becomes tricky is that in order to get texture atlases to work with greedy meshing, it is necessary to support wrapping within each subtexture of the texture atlas. Texture atlases can greatly reduce the number of draw calls and state changes, especially in a game like Minecraft, and so they are an obvious and necessary optimization.

Instead of creating many different textures, an atlas packs all of the different textures into a single gigantic texture: An example of a texture atlas for Minecraft. Now if you’ve ever modded Minecraft or looked inside a texture pack from before 1.5, the concept of a texture atlas should be pretty straightforward. Instead, a better solution is to use a technique called texture atlases. In a world with hundreds of textures and thousands of chunks, this would be utterly unacceptable from a performance standpoint. However, this would require a number of state changes proportional to O(number of chunks * number of textures). One naive solution might be to create a separate texture for each block type, and then do a separate pass for each of these textures. Today I want to write about what is probably the single most common question that gets asked regarding greedy meshes.
