Bump Mapping Techniques

By: Akbar Ali (syedali011@earthlink.net)


Blinn: “ All it takes is for the rendered image to look right”

Introduction:
When I began writing this paper I came to the conclusion that I was going to make this a “how-to” on creating and using bump-maps in real time. After some research I came to the conclusion that this was not feasible on most of today’s hardware.Only a handful of external vendors have decent support for these features I will be discussing. Most of the vendors use this method by a process called extensions, or fancy mathematical tricks

Pitfalls:

If I were to take the path of specifying my document on these extensions this would loose the whole reason why I wrote this. I wrote this so that you will get a good idea on how to go about to implement your basic bump mapping. In my opinion I feel that you should understand something, than rather than just knowing how to do something. If you decide later on to use these features, I will give you a few links to vendor specific material.

Practice:

Many problems arise in practice when you are dealing with texture mapping. Just take a look at your newest game. That is right, boot it up and take a look at the textures. Move around, strafe, shoot a rocket across the wall, whatever.
Notice anything about this? Well if you looked closely enough you would realize that the bumps on the wall are not really bumps. It is just a picture of bumps slapped on to the wall. Sure when you shoot a rocket the wall lights up (light mapping in action) but other than that it is pretty bland. In the “real world” the walls have cracks, bumps, crevices, etc.
Now take a second, close your eyes and imagine a game or a simulator where your walls, ground, steal whatever look like the ones we see everyday.
Ahh, are you back from your vision? Well in the world of computer graphics this is a feasible, we now have the methods to render these types of scenes.
One of the processes to attain these results can be achieved through a process called bump mapping.

What is it:

Well actually the word bump mapping can be kind of a misnomer. Some times people think that a certain technique is called bump mapping. This is incorrect, bump mapping is a if done correctly the viewer will see crevices, cracks etc, in a wall or any other object in which the designer feels that the object needs surface texture to.
Blinn’s initial idea of bump mapping was basically a technique where you vary the surface normal on every pixel. If you did not understand the vocabulary I used earlier don’t worry, it will be discussed later on.
Bump mapping techniques can portray just about any type of surface texture in the real world. These include but not exclude pimples, warts, treads in tires, just about anything that has texture on a flat surface in real life.

Dirt, and more Dirt:

Understanding exactly what bump mapping requires for the application developer to understand what a surface normal is. It’s not that difficult to understand but it is very vital for you to truly understand what a bump map does and the surface achieves such results.
A surface normal is a vector, which is perpendicular to the surface. Below is an illustrated example of what a surface normal is.

{Illustration 1.0} Surface Normal

Well I guess that pretty much sums up what a surface normal is. As you see it is the dark black line with a arrow. It makes a 90-degree angle with the surface, in doing this is will be classfied as a surface normal. Just in case you did not know, when a vector makes a 90 degree angle with a surface it is perpendicular.
 

Expenses:

Wow! Who would have ever thought that you would read an article that talks about expenses? Besides all that tax stuff.
Well here is the lay down. A cpu can only be so fast and a video card can only compute so much. My definition of expenses is the amount of time and energy that is stolen from these two devices (there are few others but that is besides the point).
So if I say some thing is expensive that means that the call or operation is very burdening (time consuming) on the graphics card or CPU. To achieve “true bump mapping” you must have an API(application programming interface) which supports per pixel base lighting. In computer talk this type of lighting model is called “Phong Shading”. Before you know it you’ll be saying words like this all the time.
Currently with today’s API’s we have OpenGL and Direct3d to primarily work with. Sadly, both of these API’s do not come with support for real time Phong shading.
One of the reasons for this is because it is just way to computationally expensive. Most often you will hear a game programmer complain about how he’s has to many polys in the scene and the lighting model he is using is just taking to much time. When they usually speak like this they are discussing about vertex based lighting. The lighting model goes through these vertexes and does it’s thing accordingly. It passes the vertexes location and normals through its lighting equation. Lighting is calculated though the use of light location, color intensities, surface normal. There are a few other variables depending in the ecquation but that mostly has to do with that lighting model you use. The discussion of the ecquation of the lighting model is beyond on the scope of this article. I just wanted you to get a good idea on how the lighting is calculated. As you can see the equation is pretty intense. In today’s world we have video cards that have a pipeline specifically used to accelerate those set functions.
Info:
These Video cards are dubbed to have Hardware Lighting.
Now imagine a world where instead of doing light on each polygon’s vertex, think of running that lighting equation into every pixel.
Do you see what I mean, that this can be expensive.
The amount of time which the CPU and graphics card will spend illuminating the scene are astronomical. Take my word for it.

 

Practicality:

Is this practical? Well for real time graphics this is not to feasible, at least the methods which I illustrated to you today.
Not until a while at least, but then again graphics vendors can always surprise me.
In practice this would usually be used with still picture images, or movie scenes. For example a handful of animation packages use this technique or techniques similar to this. There are a few ways to combat the calculation of per pixel base lighting, these have been done but are mostly vendor specific routines. Once these graphics routines become more of standard this will be a better option in the real time computer graphics scene.
 

Lay Down:

Well this is how you do it. As you can see we don’t have per pixel based lighting model (in general), so we are going to have to hack at it. The method which I am discussing right here is pretty straightforward. What we do is subdivide our polygons until they reach a point where they are as tiny as a pixel (that’s a lot of subdividing). After you do this you would go about distorting the surface normals. Below is an illustration of this process.

Regular Normal
 
 


Scene with pertrubed set of normals.

Now pass in your newly created vertices into your lighting model. Wala, you have some hacked bump mapping. A way to load up your surface normals is to have a height map. Usually these are created in 8 bit mode. You draw on it. Light colors would pertain to be high normal and dark colors would be low vertices or vice versa. Now read in this data, and you have a height map to take care of your surface normals. Below is how a typical height map would look like.
 
 

{Illustration 2.0} Height Map





By reading it I mean to interpret the graphics values into your vertices(normals) data.

Conclusion:

The field of bump mapping has been well documented and researched. There are other methods to achieve results that are very similar to the ways which where proposed in this paper. According to the time frame of this paper I just did not have enough time to go into detail the way the rest of the algorithms are implemented. If you are interested more about bump mapping I suggest you take stroll over to nvidia's developer section.
Mark Kilgard of Nvidia (NVDA) has written a few good papers on real time bump mapping at their site. Another method is the dot product way, this two is documented at their site.
Good luck.