Bump mapping
From DmWiki
| Table of contents |
Introduction
Bump mapping is an effect that makes a 2D texture surface seem like it's being "lit up" by a light. You'll be able to see the shadows and the "bumps" on a two dimentional texture to make it seem more realistic. There are many different types of bump mapping that each have their own hardware requirements - from dot3 bump mapping that requires a geforce2 to relief bump mapping that can't be done on todays hardware at decent speeds.
For bump mapping to work, you are going to need two textures. One is the texture itself, and the other is a height map that represents the height of each pixel on the original texture. The height map is usually just a grey scale image. Each pixel on the height map has a one to one correlation with the exact same pixel on the original texture. So if pixel (0,0) on the height map has a value of RGB(127,127,127), that would mean that pixel (0,0) is 0.5 units up. An RGB value of RGB(0,0,0) is the lowest a pixel can be, and an RGB(255,255,255) is the highest a pixel can be.
So after we have our height map, we use the height map to generate a normal map. This normal map represents the normals of each pixel on the texture. The x value is embedded in the r component, the y in the g and the z in the b. We need the normal of each pixel so that we can apply the appropriate amount of light on it.
DP3 Bump Mapping
This is the simplest type of bump mapping and works on really low end systems at decent frame rates. To achieve dp3 bump mapping we have to do two things:
- Perform dot product operation between the light vector and the normals of the pixels.
- We then modulate the result of the above operation with the original texture. So that if pixel (0,0) in the above operation had a result of RGB(127,127,127) then the same pixel of the original texture will have it's color value cut in half.
