Fast Bump Mapping

Fast Bump Mapping


Fast bump mapping relies on the fast Phong Shading technique, so, if you haven't read that yet, I suggest you do so.

You'll remember from the last couple of articles that Bump Mapping makes adjustments to the surface normal across a polygon. You'll also remember that the phong map represents the brightnesses for all possoble surface normals across a polygon. It doesn't take a genius to work out that a fast way of performing bump mapping would be to make offsets to the phong map.



The Fast Bump Map

So that's exactly what a fast bump map is. Each pixel on the map is an offset of the phong map. As you scan scross the polygon, you're interpolating the phong map, and also the bump map. At each pixel, you add the value of the bumpmap to the pointer into the phong map.

  for every pixel in polygon
    calculate current pixel in phong map
    calculate current pixel in bump map

    P = pointer to pixel in phong map
    B = value of (word) pixel in bump map

    C = byte pointed to by P+B

    write pixel of brightness C to screen
  end of loop

Implemening the bump map

Since the phong map is likely to be large, typically 256x256, one byte per pixel in the bump map is simply not enough to provide a good range of offsets. It is more practical to have one word (two bytes) per pixel. For a 256x256 phong map, 16 bits gives the full range of offsets.

There is another good reason. A two byte bump map makes it very convenient to produce the map and modify it in realtime. The high and low bytes can be considered Y and X offsets respectively.

You will have to be very careful to orientate the maps right. If you apply the bump map upside down, the bumps will look inside out. Take a look back at the previous article on fast Phong Shading. Remember that two vectors, V and H were defined. You should align the bump map on the polygon so that the Y and X offsets are along the V and H vectors respectively. Or, if you rather, define the vectors to match the bumpmap.