Never reinstall Windows XP again!
How Bump Mapping Works Print E-mail
Written by Tuan "Solace" Nguyen
Saturday, June 10, 2000
Article Index
How Bump Mapping Works
Limitations
Advantages of EMBM
Per Pixel Shading
Introduction

With the arrival of NVIDIA's GeForce 2 GTS, and 3dfx's Voodoo 5, games are going to look much more realistic than ever before. Over in one corner, we have the GeForce 2 with its transform and lighting (T&L) engine doing highly complex geometry details, while in the other corner the Voodoo 5 gives Hollywood effects with motion blur, perspective zoom/focus and full screen anti-aliasing.

All these on-board technological advances allow for more complex scenes and models without taxing your CPU.

Transform and Lighting allows a developer to increase geometry complexity in a scene whether it be the landscape or the characters. All geometry functions are done in hardware on the GPU. Before, T&L was done in software and was heavy on your local CPU.

3dfx has taken a different approach to screen complexity. They have applied a massive effects engine able to do feature film-like effects. The most talked about feature has to be FSAA (full scene anti-aliasing). This removes the "jaggies" that you see on the edges of objects. Other features include perspective zoom. This is also an effect that is used often in movies. When something important needs to be focused on, the camera focuses sharply on that object or person and everything else seems blurry.

There has been another technology that has been around (on PC gaming video cards) for a year or so and it is only beginning to take some real shape now -- bump mapping.

Actually there are numerous games out that take advantage of it, but none actually go very far in terms of mass implementation.

Bump Mapping

Bump mapping is a technique used to add more realism to images without adding a lot of geometry. Texture mapping adds realism by mapping images to geometric surfaces. Bump mapping adds per-pixel surface relief shading, increasing the apparent complexity of the surface. This uses lighting properties and indicates which parts are dark and which are light on a texture, making it look more geometrically complex because of light refraction.



Surfaces that should have a patterned roughness are good candidates for bump mapping. Examples include strawberries, oranges, stucco, wood, water, etc.

A bump map is an array of values that represent an object's height variations on a small scale. A custom renderer is used to map these height values into changes in the local surface normal. A normal is the perpendicular vector to a plane -- 90 degrees from the plane. These normals are combined with the surface normal, and the results are used to evaluate the lighting equation at each pixel.



Emboss Bump Mapping

The first type (and the most common type) of bump mapping is emboss bump mapping. The technique described here uses texture maps to generate bump mapping effects without requiring a custom renderer. This multipass algorithm is an extension and refinement of texture embossing.



-- Render the image as a texture.
-- Shift the texture coordinates at the vertices.
-- Re-render the image as a texture, subtracting from the first image.

What emboss bump mapping does is duplicate the first texture, shift it over to the desired amount of bump, darken the texture underneath, cut out the appropriate shape from the texture on top, and blend the two textures into one. This is called a two-pass emboss bump mapping because it requires two textures.

Emboss Bump Mapping (cont.)

Lets do an example on a one dimensional bump map for simplicity's sake. The map only varies as a function of s. Assuming that the height values of the bump map can be represented as a height function f(s), then the three step process above would be like doing the following: f(s) - f(s + shift). If the shift was by one texel in s, you would have: , where w is the width of the texture in texels and l is the length. This is a different form of which is just the basic derivative formula. So shifting and subtracting results in the first derivative of f(s), f'(s) -- f-prime at s.

In the two dimensional case, the height function is f(s,t), and shifting and subtracting creates a directional derivative of f(s,t). This technique is used to create embossed images.

What does this all mean? All this does is simulate a texture's height in reference to a light source. If one part of the object is closer to the light, it will be lit up more brightly. Now if you apply those simulations to a flat texture and point out where light should hit and not, then you can simulate 3D roughness on the flat plane without adding more geometric detail -- actual polygonal bumps.

Limitations to Embossing:

Bump Map Sampling: The bump map height function is not continuous, but is rendered right into the texture, making it permanent. The resolution of the texture affects how accurately the bump map is rendered. Increasing the size of the bump map texture (the duplicate of the actual texture map) can improve rendering of extreme heights in the texture.

Texture Resolution: The shifting and subtraction steps produce the opposite direction map. Since this is a forward differencing technique, the highest height component of the bump map increases as the shift to the bump map is made smaller. As the shift reduces in size, the texture coordinate precision must increase in accuracy. The map shift can become smaller than the texture filtering implementation can handle, leading to texture noise and aliases effects making the final image seem ripped or broken and can turn out perceptively incorrect.

Surface Curvature: The height coordinates are different for each point on a curved surface. This technique approximates this by interpolating the height transforms for each vertex on the polygon being bump mapped. For polygons with very different vertex normals, the interpolation will not work because of major differences. It's like being asked to guess what a secret is without a clue. If you have more clues, you will be able to guess more accurately.

Maximum Bump Map Slope: The bump map perpendiculars used in this technique are good approximations if the bump map slope is small. If there are steep tangents in the bump map, the assumption that the bump perpendicular length is equal to 1 becomes inaccurate, and the highlights appear too bright because it assumes that that point on the bump is very close to the light source, which it isn't. It is merely much more higher than the other bumps. Embossing requires that all bumps on a particular surface be the same.



The above diagram illustrates that the embossing effect no longer works when the light source moves past a certain degree of incident. For the lighting to work, the reflected angle must remain acute or smaller than 90 degrees from the normal.