Realism can be increased by showing a distant background.
Idea: Enclose the whole scene in a very large cube. Texture the interior faces of the cube with the background.
Assume that the viewpoint remains near the centre of the cube. Then only the direction is important when determining what texel is visible from position $p$ in direction $d$.
The faces of the cube are labelled with the corresponding positive and negative axes. The set of six textures on the interior faces is called a cube map.
Consider a 2D cube map consisting of a square with four faces. In direction $(x,y)$ from the centre, what texel is visible?
The component of $(x,y)$ with the greatest magnitude determines which of the four faces is visible.
Below, $|x_1| > |y_1|$ and $x_1 > 0$, so $x^+$ has the texel. Also, $|y_2| > |x_2|$ and $y_2 < 0$, so $y^-$ has the texel.
The coordinates on the face are determined by dividing the other coordinates of the direction by the magnitude of the coordinate of greatest magnitude.
Above, the $x^+$ face has the texel. If the origin-to-face distance is 1, the range of coordinate values on any face is $[-1,+1]$ and the coordinates of the texel are $({x \over |x|}, {y \over |x|})$ = $(1, {y \over |x|})$.
Finally, the ${y \over |x|}$, which is in the range $[-1,+1]$, must be mapped to the usual $[0,1]$ range of texture coordinates: $$ {y \over |x|} \longrightarrow 0.5 {y \over |x|} + 0.5 $$
Cube maps can provide a very distant background.
Cube maps can be used to reflect the environment off of specular objects: When looking at a point on an object from direction $V$, the ideal reflection direction, $R$, can be calculated. Then $R$ can be used to look up a texel in the cube map, which will appear to be reflected off the surface toward the eye.