This chapter introduces the classification of graphics-related topics, mainly including Skybox rendering,environment mapping,fog, and color blending (sky rendering, background texture mapping, fog, color mixing). The first two effects have one thing in common: they are all achieved through texture cubes. Learning this knowledge will allow you to go further on the road to graphics.
Texture Cubes
A texture cube (also known as cube map) is a collection of 6 2D textures. Each texture corresponds to the side of a cube centered on the origin of World Space and aligned to the axis. These textures can be stored separately in a file, or stored in a file in the same DDS format (3rd, "Tools of the Trade" discussed in DDS format). Figure 8.1 shows the texture cube in which all textures are stored in the same file, and each side of the corresponding cube is marked.
Figure 8.1 A Texture cube. Each of the face are labeled with the corresponding axis. (Texture by Emil Persson.)
Creating Texture Cubes
There are a variety of tools to create texture cubes. For example, Nvidia's DDS generic package contains a command-line tool, NVDXT, to create texture cubes (links are provided on the companion website of this book). NVDXT a series of individual textures as command-line arguments, compiling the textures into a texture cube and storing them as DDS-formatted files.
Microsoft provides DirectX Texture tool for creating DDS files, which are included in the standalone DirectX SDK installation package (not part of the Windows SDK). In Figure 8.2, a texture cube is loaded using DirectX Texture tool, and the cube Map face menu item is selected under the main menu. Use this menu recommendation to specify a side of the cube map to display.
Figure 8.2 The DirectX texture Tool. (Texture by Emil Persson.)