reprinted from the Wind Yu Chong Unity3d Tutorial CollegeThis lecture is divided into two partsOne: PrincipleTwo: Realize
One: Principle
(1) Eyes and lightLet's take a look at a rough surface.
from a distance, the only evidence that you can judge this object to be rough is that the brightness on its surface changes. Your brain can get these light and dark patterns, and then determine that they are part of the surface that has a bump. This is illustrated by a picture on the left. You can see that it is an embossed surface. Some moments and letters are printed on the surface, but they touch the glass like a hidden monitor. If the image is in the right place, it does not need to do any other work except to change the brightness. then you might ask: How do I know which points are lit and which ones are darker? It's not hard. Most people live in an environment where most light sources come from above (the translator notes: For example, the main light from the sun comes from the day, and the main light comes from the fluorescent lights on the ceiling at night). So the upward tilt will be brighter, and the downward inclination will be darker. So this phenomenon makes it possible for your eyes to see the bumps in the light and dark areas of an object. The relatively bright blocks are judged to be facing up, and the relatively dark blocks are judged to be facing down. So I just need to paint the lines on the object simply. If you want more evidence, here's an almost identical figure, unlike the previous one, which rotates 180 degrees. So it's an image reversed from the previous picture. Those areas that previously seemed to be recessed, now look convex. at this point your brain is not completely deceived, and the visual impression you have left in your head makes you still have the ability to judge that this is the previous picture, except that its light source has changed, and that your brain may be forced to judge that it is the first picture. In fact, as long as you stare at it and try to imagine the light shining from the lower right, you will understand that it is concave (the translator notes: Because of the habits of daily life, you will easily judge these figures as protruding figures, but because of the impression of the previous contrast chart, You may be particularly aware that these tiles are still recessed, but that the judging method does not conform to our daily routines, since most light is not irradiated from above, but from the bottom up.
(2) NormalAs mentioned in the previous 15, normal reflection of light is very important. In general, the normal of a point on a triangle is equal to the normal of the vertical whole triangle type. But we can get a more realistic picture effect by getting normals from grayscale or from normal maps.
Two: Realize
(1) overlay with grayscale imageThis method is also called fake bump mapping, false bump map. Because it does not change the position or normal of the surface point of the object. The bump map is simply superimposed on the already rendered surface, causing a disturbance in the brightness so that the eye is thought to be concave and convex. Computational complexity is the basic addition and subtraction. The disadvantage is that the light and dark areas are not changed as the direction of the lights changes.
(2)
Generating NormalsBecause (1) the method has a mishap that cannot be reacted to light. So there's a more realistic way: calculate normals with height. There are many ways to calculate normals highly, and here is a broad introduction to CG.Method:when sampling a point on a grayscale map, not only the height Hg of the point, but the right of the point is taken.Point Hr and point above the point Ha takes these three points as 2 vectors: The first vector V1 is (1,0,HR-HG) the second V2 is (0,1,HA-HG) The normal is the unit of V1 and V2 of the vector product. If the result is stored on a graph, a normal map is generated. Unity3d can do this for us, convert the grayscale image to a normal map. is the following (3)
(3)
height map to normal map in unitySpecific steps: 1) Import HEIGHTMAP2) Select to change texture type to normal map3) tick create from grayscale4) Applyafter that, we saw that the graph in unity became a blue normal map directly.
The Ps:unity3d bump map Shader, bumped diffuse, is the normal mapping method. This is the normal map of RGB, which is usually blue. Unity comes with a shader that does not directly use grayscale, and provides the ability to turn normal maps into grayscale images.part of this article is derived fromhttp://freespace.virgin.net/hugo.elias/graphics/x_polybm.htm
Unity3d Tutorial Shader article: 19th, bump map