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.

Cube maps

Up until this point, any time we have manipulated a texture, we have specified a texture target of TEXTURE_2D ...

Get WebGL Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.