In computer graphics, sphere mapping can refer to either of two methods that are used to apply an image or procedural texture to a three-dimensional (3D) sphere. Generically, sphere mapping is used to apply a two-dimensional (2D) rasterized image to the surface of a sphere, distorting the flat image to match the polar coordinates of the shape. Sphere mapping also is used to describe a form of environmental mapping that uses a pre-rendered image of the scene that is mapped onto the surface of a sphere in a way that makes the sphere appear to be reflecting the environment around it, like a ball made from perfectly reflective metal. Both types of sphere mapping result in a three-dimensional sphere that has a texture applied to its surface, although the environmental mapping distorts the image in a different way than spherical projection mapping.
When used to apply a texture to a sphere shape, sphere mapping takes a 2D image and projects it onto the surface of the sphere being textured. The image follows the coordinate system of the sphere, where each vertex on the surface aligns much like the intersections of longitude and latitude lines on a globe. This means that, as the image reaches the poles of the sphere on the top and bottom, the image will start to compress toward a single vertex, effectively distorting the image. In many cases with a properly created texture image, this gives a more natural appearance to the sphere as opposed to using cube mapping or cylinder mapping. This technique is used to create graphics and animations of textured spheres such as the planet Earth with satellite images of the oceans and continents.
When used in environmental mapping, sphere mapping is a fast way to create an object that seems to have a mirror surface. The process calculates the vectors of light from the surface of the sphere, and that vector is then translated into coordinates that are used to find the color within a 2D image. Unlike projection sphere mapping, the reflective version distorts the image in a slightly different way.
One advantage to using environmental sphere mapping is that it is very fast compared to other methods, such as ray tracing, which dynamically calculates the reflection based on the objects in the scene. The method is fast because the reflection actually is a pre-rendered image. This leads to some complications with the technique, because dynamic changes to the environment, or objects that are moving in the scene, will not be shown in the reflection. Additionally, because the perceived reflection is static, concave shapes that receive the mapping will not reflect themselves, causing a sometimes confusing visual effect.