Bump mapping is a way of simulating fine details such as bumps or wrinkles in a surface by modifying the surface normals. Bump mapping can be used to simulate features that would otherwise take a large number of polygons to model.
This technique is a normal-perturbation rendering technique for simulating lighting effects caused by patterned irregularities on an otherwise locally smooth surface.
This technique is a multi-pass per-pixel lighting computation using pixel shaders and vertex shader hardware features, thus classical OpenGL Gouraud lighting is deactivated when a shape is rendered using the bump mapping technique. |
Depending on your hardware capabilities, bump mapping may not be available. This technique uses standard OpenGL 1.3 features but can also work with previous OpenGL versions if specific OpenGL extensions are available. The method SoBumpMapping::isSupported() will indicate if bump mapping is supported by your graphics board. |
The main idea of bump mapping is that, instead of using a texture to modify the color of a surface, we apply a texture, called a normal map, height map, or simply bump map (generic term), to modify the surface normals. The surface patterns are encoded in the bump map texture.
The texture is called a normal map if it stores normals. The bump map texture is in this case an RGB texture, with x, y, and z corresponding to the red, green, and blue components respectively.
The texture is called a height map if it stores heights. The bump map texture is in this case a monochrome texture where each monochrome value represents a height, with white used for high areas and black for low areas. A height map is converted internally to a normal map.
As previously described, a bump map is a texture where heights (a height map) or normals (normal map) are encoded.
Like classical texture mapping, texture coordinates (s and t) are assigned to each vertex of a polygon, to control how the bump map is mapped onto the geometry.
The following figure illustrates this.
Additionally, each normal stored within the normal map can be expressed either in the space of the object called “modeling space” or in the space of the polygon called “tangent space.”
The “tangent space” coordinate system is convenient for applying repetitive wrinkle patterns. |
When bump mapping, there are really two surface normals that should be considered for lighting: the unperturbed normal N based on the shape geometry, and the perturbed N', which is based on the surface’s small-scale microstructure stored within the normal map.
Self-shadowing corrects lighting which would normally only be based on the perturbed normal N' by taking into account the unperturbed normal N.