Techniqueintro
Bump mapping
Also called Blinn bump mapping.
Perturb the shading normal by the gradient of a height texture, so that a flat surface looks wrinkled without changing its geometry.
Bump mapping makes a smooth surface look rough by changing only the normal that the lighting uses. A scalar height texture describes small bumps, and the method tilts the normal by the slope of at each point, as if the surface had moved by along its normal. The geometry and the texture coordinates do not change. Normal mapping stores the tilted normal itself in a texture in place of computing it from a height. Parallax mapping and parallax occlusion mapping also move the texture coordinate by the view, so the bumps seem to shift. Displacement mapping moves the geometry, which also changes the silhouette and the shadows.
In plain words
Light makes a bump visible mainly through shading: the side of the bump that faces the light is bright and the other side is dark. The eye reads this pattern of light and dark as shape.
So keep the surface flat, but at each point tell the lighting that the surface is tilted. The tilt comes from a gray image of heights: where the heights rise to the right, tilt the surface to the left, and so on. Steeper slopes give stronger tilts.
The result looks bumpy from the front. It still looks flat at the edges of the object, because the outline does not change, and the bumps never hide each other.
When it applies
- The detail is small compared with the object: pores, scratches, orange peel, cloth weave, ripples, hammered metal.
- The view is not at a grazing angle, and the outline of the object does not need to show the detail.
- A height texture is at hand, or a procedural height such as Perlin noise or fractal noise whose derivative can be computed.
- The lighting uses the normal, as in Blinn-Phong or a physically based model.
- It does not apply when the relief must hide parts of itself, cast shadows on itself or change the outline. Use the parallax methods or displacement mapping then.
The template
The inputs are a surface point with the tangents and , the normal , the unit normal , and a height with a scale .
- Read the slopes of the height, and . For a texture, use central finite differences one texel apart, , or the derivatives of a filtered lookup. For a procedural height, use its analytic gradient.
- Think of the displaced surface . Its tangents are and the same for .
- Drop the terms and , which are small when is small compared with the radius of curvature of the surface.
- Take the cross product of the two tangents. This gives Blinn's perturbed normal , since and the term in vanishes.
- Normalize and use it in place of in the lighting of the pixel.
- In a tangent frame with unit tangents and that are orthogonal, step 4 becomes , the vector in the coordinates .
Steps 2 to 4 are exact except for the dropped terms, so on a flat base, where , the normal of step 4 is the exact normal of the displaced surface. This is a proved property. On a curved base it is an approximation. The scale and the texel step are tuning.
Classic examples
A trace. On the plane with , and , let the height be , with , and let the light come from the unit direction . Then and .
| normal after step 5 | |||
|---|---|---|---|
| any, flat surface | |||
| 0 | |||
| 0.25 | 0 | ||
| 0.5 |
The slope that faces away from the light is dark, the slope that faces it is bright, and the tops and the bottoms keep the flat shading. These are the stripes of light and shade that read as ridges.
Procedural surfaces. Perlin added the gradient of Perlin noise to the normal in 1985, for bumpy surfaces and water waves. A sum of octaves of fractal noise gives rough stone, and of Worley noise gives cracked tiles, both with analytic or numeric slopes.
Normal map baking. The normal of step 6 can be computed once per texel and stored. This is how a height map becomes a normal map, and it is a common step in texture tools.
Ripples on water. An animated sum of a few sine waves in gives moving highlights on a flat water plane with no extra geometry.
Variations
- Tangent space bump mapping. Peercy, Airey and Cabral (1997) moved the computation into a tangent frame per vertex, interpolated over the triangle, which made it practical in hardware.
- Bump mapping without a tangent frame. A pixel shader can take screen-space derivatives of the position and of the height, and build the perturbation from them. This needs no stored tangents, but the derivatives are coarse, per block of 2 by 2 pixels.
- Normal mapping. Store the result of step 6 in place of the height. This trades memory for fewer texture reads and avoids the finite differences.
- Parallax mapping. Also shift the texture coordinate by the view direction and the height. See parallax mapping.
- Bump to displacement. For close views, move the vertices with the same height, as in displacement mapping, and keep the bump for the detail finer than the mesh.
Pitfalls
- Flat at the outline. The silhouette stays smooth, and at grazing angles the shading shows bumps that the outline denies.
- No self-occlusion and no self-shadowing. Bumps never hide or shadow each other, so deep relief looks painted.
- Sign and handedness. If the texture's axis runs the other way from , or the mesh is mirrored, the bumps look inverted. Check with a light from one side.
- Scale of the slopes. The slopes depend on the texture scale: the same height map on a smaller area has steeper slopes. Make depend on the world size of a texel, or the strength changes with the tiling.
- Aliasing. Fine bumps far away alias into sparkles, because the normal varies faster than the pixel grid. Mipmapping the height smooths the slopes, but it also removes the roughness. See aliasing.
- Shading normal facing away. A strong perturbation can tilt the normal away from the viewer or below the surface, which gives black spots or light leaks. Clamp the tilt or the scale.
Exercises
- Derive the formula of step 4 from steps 2 and 3, and show that it reduces to the formula of step 6 on a plane with an orthonormal tangent frame.
- For on a plane, find the largest tilt angle of the normal as a function of .
- Show that scaling by a factor (the texture repeats times more often) scales by . What must happen to to keep the look?
- Compute the normal from a central difference on a height texture with values , and at , and , with and .
- Explain why the dropped term matters on a sphere of radius when is close to , and what shape the true displaced surface has then.
References
- James F. Blinn, Simulation of wrinkled surfaces, SIGGRAPH 1978, the perturbed normal from the partial derivatives of a bump function along the two surface tangents (general locator)
- Mark Peercy, John Airey and Brian Cabral, Efficient bump mapping hardware, SIGGRAPH 1997, the perturbation in a tangent frame per vertex, interpolated over the triangle (general locator)
- Matt Pharr, Wenzel Jakob and Greg Humphreys, Physically Based Rendering, From Theory to Implementation, third edition, Morgan Kaufmann, 2016, Section 9.3, Bump Mapping
- Tomas Akenine-Möller, Eric Haines, Naty Hoffman, Angelo Pesce, Michał Iwanicki and Sébastien Hillaire, Real-Time Rendering, fourth edition, CRC Press, 2018, Section 6.7, Bump Mapping, from page 208
Where this leads
About this page
The build computes these levels from the evidence in the repository. Each row says what the next level needs. Read what the levels mean.
| Ladder | Level | What the next level needs |
|---|---|---|
| Human proof | H0 no proof |
|
| Lean | L0 no Lean part |
|
| Visual | V0 none |
|
| Writing | W2 basic |
|
Tag 2SWA67 Edit this page History Report an error Markdown