First of all, games originally used vertex lighting. This is a technique in which the lighting for each vertex is individually calculated, then the color of the surface is actually interpolated. This is basically an approximation.
Vertex Lighted Sphere
But now, with the advent of more powerfull graphics cards, we are able to come closer and closer to more realistic lighting. From that, emerged per-pixel lighting. This technique calculates the lighting color of each and every pixel that is drawn on the object.
Per-pixel Lighted Sphere
As you can see, this is much closer to actual lighting and specularity.
Now to determine the orientation of any suface in relation to a light, normals are used. These are generally a perpendicular line to the surface showing its orientation. The concept of normal mapping is to assign a seperate normal to each pixel, and to slightly change the normal to effect the way light falls on the surface. When this happens, the specularity, and other shading is actully distorted to give the appearance of bumps and troughs, except in predictable possitions. These are normally added on to a diffuse (color) texture to make it seem as if a flat surface, such as one textured with bricks has all of the individual bumps. This gives the appearance of detail without actually having detail.
Sphere with rock texture (no normal map)
With the two examples above, the difference is pretty obvious. Unfortunately, to be able to preform realtime normal mapping, Pixel Shader 2.0 is required. This is because it is done through shader and fragment programs that run on your graphics card. You can do software (on the CPU) normal mapping, but it is extremely slow, in comparison.
To actually change the normals of the surface, an image called a normal map is used.
Normal map
Based of the RGB values, the direction of the normal is determined.
- Red(0 to 255) maps to X(-1 to 1)
- Green(0 to 255) maps to Y(-1 to 1)
- Blue(0 to 255) maps to Z(0 to 1)
Because of the fact that normals must point away from the surface, negative Z values cannot be used.
Using normal mapping, various effects can be achieved.
No comments:
Post a Comment