Term Project, 2003
Bump mapping is a way to add surface detail without the need for additional surface geometry. It is accomplished by perturbing the surface normal of each pixel, then evaluating the lighting equation at each pixel. We will investigate this using a 3D extension of PostScript called ps3d.
The angle between the light vector and the face's normal vector determines how much a face is shaded. Given a light vector L and a normal vector N (both are assumed to be of length 1), the cosine of the angle A between them is given by cos A= L N. This returns a number between -1 and 1. A transformation R[-1, 1] => R[0,1] is then applied to this number, which is then used to apply the corresponding shade of gray to the surface. Figures 1 and 2 give examples of this.
A 3D object is composed of many faces. Each of these has a normal vector, as shown in figure 3. Some objects have more geometric detail such as the object in figure 4. It is possible to perturb the normals of figure 3 so that they look like figure 4 as shown in figure 5. This will give the illusion that figure 5 looks like figure 4, provided that the bumps are "not too high." (We'll see examples of this later.)
4. Bump Mapping In Action
Since I cannot do per pixel lighting directly, I'm going to do my best to approximate this by constructing each surface as a grid (Figure 6) and then perturb the normal of each cell of the grid (Figure 7) to mimic a simple block pattern. If scaled appropriately, this should be a reasonable approximation of the real thing. What I end up with is a data structure containing 1 pixel by 1 pixel faces and their associated normals, which I have perturbed.
Figures 8 through 10 show examples of this simple block pattern. Nifty. Figures 11 through 13 show the same block pattern, only this time it's really rendered as a 3D object, not just on a plane. Figures 10 and 13 highlight the biggest problem with bump mapping. Notice how in Figure 13, the far edge of each block is obscured, Figure 10 just looks flat. If the bump is too high, or viewed from a sharp angle, it becomes pretty obvious that it really is only 2 dimensional.
Bump mapping provides a pretty convincing way to add detail to a 3D object provided that the bumps are not too high or that they're not view at a sharp angle. My bump mapping proved to be very slow, and couldn't compete with it's 3D equivalent. This is due primarily to the way the shading was handled. Since I couldn't manipulate pixels directly, I had to approximate them using faces roughly the size of pixels. Therefore, the bump mapped block, which was 18x18 "pixels", had 324 faces to shade versus the real 3D object's 5 faces.
NOTE: You must have both ps3d.inc and block.inc in the same directory as GS itself in order to run blockA.eps, blockB.eps, and blockC.eps. You must have ps3d.inc in the same directory as GS in order to run block3dA.eps, block3dB.eps, and block3dC.eps.
Casselman, Dr. W. A Manual of Mathematical Illustration
Blinn, J. F. "Simulation of Wrinkled Surfaces", Computer Graphics, Volume 12 (3), pp. 286-292 SIGGRAPH-ACM (August 1978)