Bump mapping (Bump mapping)

Source: Internet
Author: User

Bump mapping is very much like Texture mapping. However, where Texture Mapping added colour to a polygon, Bump Mapping adds, what appears to is surface roughness. This can has a dramatic effect on the look of a polygonal object. Bump Mapping can add minute detail to an object which would otherwise require a large number of polygons. Note that the polygon was still physically flat, but appears to a was bumpy.

Take a look at the cube on the left. If you look closely, you can see lots of detail on it. It looks as if it must has been made from millions of tiny polygons, but was made from just 6. You might ask how this differs from Texture Mapping. The difference is, a Bump map is a Texture map, responds to the direction of the light.

The theory behind Bump Mapping

Ake a close look at a rough surface. From a distance, the only-the-know it is rough are by the fact that it's brightness changes up and down across it's Sur Face. Your Brain can pick out these bright and dark patterns and interpret them as bumps on the surface.

The little picture on the left illustrates this. What do looks like an embossed surface? Some rectangles and letters has been pressed into it, but if you touch it, it just feels like the glass of your MONITOR.N Othing more have been done than change the brightness if the image is just the right places, your brain does the rest. This technique can is used to add real feeling to a polygon.

So how do I know which bits to do bright, and which to make dark? It ' s easy. Most people spend their lives in a environment where the main light source is above them (except US spods of course, whos E main light source comes from the monitor). So surfaces angled upwards tend to being brightly lit, and downward inclined surfaces tend to be darker. Therefore It follows if your eyes see light and dark areas on an object, they would interpret them as bumps; Lighter bits it takes as up-facing, and darker bits it takes as down-facing. So, I just coloured the lines on the image accordingly.

As if you needed any more evidence, here are exactly the same image, but rotated. degrees. It appears to be the inverse of the previous one. Those areas that appeared to being pushed in, now seem to has popped out, and Vice-versa.

Now, your brain are not entirely stupid. If you had visual evidence that the inverted image is lit from underneath, your brain would again interpret it as the FIR St image. Infact, if you stare, and think hard enough on a light source comming from the bottom right, you can make that happen.

What is a Bump Map

A bump map is very much like a texture map. However, rather than containing colours, it contains bumps. The most common-represent bumps is by the height field method. A greyscaled Texture map is used, where the brightness of each pixel represents what much it sticks out from the surface (s EE image on right). This is a very convenient-to store a bump map, and it's simple-to-make. How this information are used by the renderer would become apparent later. Of course, you needn ' t limit yourself to such simple patterns. You can have wood, stone, peeling paint and anything you want.

So how ' s it done

Bump mapping is an extension of the Phong shading technique. In Phong shading, the surface normal is interpolated over the polygon, and that vector is used to calculate the Brightne SS of that pixel. When you add bump mapping, your is altering the normal vector slightly, based on information in the bump map. Adjusting the normal vector causes changes in the brightness of the pixels in the polygon. Simple.

Now, there is several ways of acheving this. I have never actually programmed real Phong shading or bump mapping, only the fast versions (which work very nicely thanky OU), so I am kind of making this next bit up as I go along. Bare with me.

OK, so we need a method for converting the height information on the bump map to vector adjustment information for the P Hong Shader. This isn't so hard-to-do, but it might was tricky to explain.

OK, so first you'll need a to convert the bumps on the bumpmap into little vectors, one vector for each pixel. Take a look at the zoomed-in view of a bumpmap in the left. The lighter pixels stick out more than the darker ones. Get the picture? Now, for each pixel, a vector must is computed. These vectors represent the incline of the surface at that pixel. The picture is on the represents. The Little red vectors point in the ' downhill ' direction.

There is many ways to calculate these vectors. Some is more accurate than others, but it depends exactly what's mean by accurate. One of the most common methods are to calculate the X and Y gradient on that pixel:

X_gradient = Pixel (x-1, y)-pixel (x+1, y)

Y_gradient = Pixel (x, y-1)-pixel (x, y+1)

With these-gradients, you'll now need-to-adjust the normal vector of the polygon at the. Here are the polygon, with it's origional normal vector, n. Also shown is the vectors which is going to being used to adjust the normal vector for this pixel. The vectors must is aligned with the BumpMap for the polygon to be rendered correctly. i.e. the vectors is parallel to the axes of the bumpmap.

On the right is the bump map, and the polygon. Both pictures show the U and V vectors.

Now you can see the new Normal vector after adjustment. The adjustment is simply:

New_normal = Normal + (U * x_gradient) + (V * y_gradient)

With this new_normal vector, you can procede to calculate the brightness of the polygon at that point, using the usual pho ng shading Technique.

Bump mapping (Bump mapping)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.