[Translation] Understand the Bump Mapping Technology

xiaoxiao2021-03-06  46

I translated this tutorial is to help those who have interested in graphic rendering technologies but still can't find free Chinese learning materials. In my side, there is no predecessor who is engaged in computer professional, from the basic operation of WINDOWS, my computer technology is completely self-study, and the history of calculative programming is also in the past five years. I often spend more than half of the learning time used to check the learning materials (remember when I learn the GIF image format, I use it for nearly two weeks to prepare the procedure and display the GIF picture. The main reason is that the information is not enough, only to see One or two short range of tutorials to write the program, most of which is spent on debug code and guessing). So I have the same feeling about those who are not engaged in computer majors, and there is no computer master - check a bunch of materials is the most painful process in self-study. These days, I am studying the Bump Mapping algorithm. After reading a simple e-literary tutor, I think I really should make a little meager contribution to China's tutorial industry. I am not a 3D master, but it is just a newbie of OpenGL, so it can only be translated first. I also hope that my translation sample can throw the jade, seeing more and more masters in China can truly write some things, and share them with you. Because the level of this is limited, the translation is inevitable, there is a mistake, please correct it.

In order to respect the original author, it is also possible to use the original article in response to the original text:

Http://freespace.virgin.net/hu.comlias/graphics/x_polybm.htm

This article is relatively simple. After reading it, it doesn't make you truly master the technology, but it has a transition role. It introduces some basic principles of Bump mapping. I believe that you will see it. Bump mapping improves the tutorial, it is easier.

Surface mapping Bump mapping

[img] http://freespace.virgin.net/hu.elias/graphics/bumpmap2.gif [/ img] Configuous mapping and texture mapping are very similar. However, the texture map is applied to the polygon, while the embossing is applied to the polygon. This will have an attractive effect on polygons. We only need to add a little information to the original item to use a large number of polygons. It should be noted that this object is flat, but it looks rough. Let's take a look at the cube on the left. If you look at it very closely, you will find a lot of details above it. It seems to be composed of thousands of polygons, in fact, it is only composed of six rectangles. You may ask: "What is the difference between this and texture mapping?" The difference is that the concavo-convex mapping is a texture mapping in the light direction.

(1) Principle behind the uneven map

[img] http://freespace.virgin.neet/hu.elias/graphics/bumpmap3.gif [/ img] Let's take a look at a rough surface. From a distance, you judge that the only evidence of this object is rough is that the brightness of the surface is changed. Your brain can get these brightly andd and different pattern information, and then determine that they are unevenness in the surface. This picture on the left will illustrate this. You can find it is a relief surface. Some rectifications and letters are printed on the surface, but they touch it as a glass of hidden monitors. If this image is in an appropriate location, then it does not need any other job in addition to changing the brightness.

Then you may ask: How do I know what to do, what is going to be dark? This is not difficult. Most people live in such an environment - most of this environment comes from above (translator Note: such as the main light from the sun from the sun, the main light from the ceiling from the ceiling ". So it will be brighter, and it will be darker. So this phenomenon allows your eyes to see a dark area on an object, it can judge its unevenness. The relatively bright block is judged to face, and the relatively dark block is judged to face. So I only need to simply get color on the line on the object. [img] http://freespace.virgin.net/hu.elias/graphics/bumpmap4.gif [/ img] If you want more evidence, there is almost the same picture, it is different from it. Rotate 180 degrees. So it is an image inverted by the previous figure. The area that has previously appeared is recessed, and now it seems to be convex.

At this time, your brain has not been completely deceived. The visual impression in your brain makes you still have the ability to judge that this is the previous picture, but its light source has changed, it is from small to your brain. It is the first picture. In fact, you only need to keep it at it, and try to illuminate the light from the lower right direction, you will understand it is concave (translator Note: Because of daily life habits, you will easily take these graphics It is judged that the convex graph, but because of the impression of the previous alignment, you may pay special attention to these pieces actually concave, just judging the method does not meet our daily habits, because most The light is not illuminated from above, but is illuminated from bottom to.

(2) What is a concave convex (Bump Map)

The concave convex and texture maps are very similar. However, the difference is that the concave convex map is not color information, but concave convection information. The most common method is to be implemented by storing height values. We want to use a gray texture map, the gray brightness reflects how much each point is protruding (see the right). This is a very convenient way to save the concave convex map, and this figure is easy to make. What is the specific renderer? You will understand it under the next. Of course, you don't have to limit these simple graphics, you can expand, use it to do wood, do a stone, do your paint wall, do anything you want to do.

[img] http://freespace.virgin.neet/hu.comlias/graphics/bumpmap5.gif [/ iv]

(3) What is it working?

Concess mapping is an extension of pHong shading technique, just in complementing rendering, the normal of the polygon surface will be changed, this vector is used to calculate the brightness of this point. When you add a concavo-convex map, the normal vector changes slightly, how to change, based on a concave-convex map. Changing the normal vector changes the color value of the polygon. It's that simple.

Now, there are several ways to achieve this (translator Note: This purpose refers to changing the normal vector). I don't actually write a procedure for complementing color rendering and concavity mapping, but I will introduce a way I like it here!

Now we need to convert the height information in the uneven diagram into the adjustment information of the normal rendering. This is not difficult to do, but explain it.

[img] http://freespace.virgin.net/hu.elias/graphics/bumpmap6.gif [/ img] Now we now convert the information of the concave bit map to some small vector - a vector corresponds to a point . Please look at a splice map on the left side. The relatively bright point is more high than the relatively dark point. Is it clear? Now calculate the vector of each point, these vectors are characterized by the tilt of each point, see the depiction of the figure below. The red small dots in the figure indicates that the vector is down: [IMG] http://freespace.virgin.net/hugo.gif [/ img]

There are many ways to calculate vector, different methods are different, but what method chooses to depends on what level you ask for accuracy. The most common method is to calculate the inclination of X and Y on each point:

[color = # ff0000] x_gradient = pixel (x-1, y) - Pixel (x 1, y) [/ color] [color = # ff0000] y_gradient = Pixel (x, y-1) - Pixel (X, Y 1) [/ color]

After you have drawn these two accuracy, you can calculate the normal figure of the polygon.

[img] http://freespace.virgin.net/hu.elias/graphics/x_n1.gif [/ img] [img] http://freespace.virgin.net/hu.elias/graphics/x_n2.gif [/ IMG]

There is a polygon in the figure, and one of its normal vectors - N is drawn. In addition, there are two vectors that will be used to regulate the normal vector. These two vectors must be aligned with the uneven diagrams of the currently rendered polygon, in other words, they should use the same coordinate axis with the uneven map. The descriptions below are concave bunction and polygons, respectively, both of which are two vectors of u, v (translator Note: the two axes of the plane 2D coordinates):

[img] http://freespace.virgin.net/hu.elias/graphics/x_t1.gif [/ iv]

[img] http://freespace.virgin.net/hu.elias/graphics/x_t2.gif [/ iv]

Now you can see the new normal of the adjusted. This adjustment formula is simple:

[color = # ff0000] new_normal = NORMAL (U * x_gradient) (v * y_gradient) [/ color]

With the new normal vector, you can calculate the brightness of each point of the polygon by complementing the rendering technique.

转载请注明原文地址:https://www.9cbs.com/read-73752.html

New Post(0)