Cube maps
Earlier in this chapter, we mentioned that aside from 2D textures the functions we've been discussing can also be used for cube maps. But what are cube maps and how do we use them?
A cube map is, very much like it sounds, a cube of textures. Six individual textures are created, each assigned to a different face of the cube. The graphics hardware can sample them as a single entity, using a 3D texture coordinate.
The faces of the cube are identified by the axis they face and whether they are on the positive or negative side of that axis.
Up until this point, any time we have manipulated a texture, we have specified a texture target of TEXTURE_2D
. Cube mapping introduces a few new texture targets that indicate that we are working with cube maps, and which face of the cube map we're manipulating:
TEXTURE_CUBE_MAP
TEXTURE_CUBE_MAP_POSITIVE_X
TEXTURE_CUBE_MAP_NEGATIVE_X
TEXTURE_CUBE_MAP_POSITIVE_Y
TEXTURE_CUBE_MAP_NEGATIVE_Y
TEXTURE_CUBE_MAP_POSITIVE_Z
TEXTURE_CUBE_MAP_NEGATIVE_Z
...