First introduce yourself ...... If you say this is self-hyping, I agree. First, fxcarl is a different guy from 3D art. Although I really want to develop in the direction of technical artists. What I can do right now is to write shaders. After the project is completed, the real-time lighting model will be made public ...... But that's the end. Now I just want to work with the normal map discussed by my colleagues over the past two days. Here I will talk with most artists about the "Concave and convex Paster technology" from another perspective"
First of all, I would like to say that the research on the concave and convex pasters in the computer graphics field started at the end of 1970s and has nearly 30 years of history. Normal map is only a very popular concave and convex Paster technology. Here we will introduce some of the currently used Paster technologies in games and new generations of hosts such as xbox360 and playstation3.
1. bump mapping
Friends who have done CG must know bump map earlier than fxcarl. This texture map is a gray scale map that describes the concave and convex of the target surface with gray changes on the surface. Therefore, this texture is black and white. If it saves space, you can even requisition the alpha channel of the texture for bump. It is worth noting that what is stored on the texture surface is the height field, that is, the height difference between each point and the original surface. Remember that the color of each point is not color, but height or a value! Therefore, any operations on this texture will affect the 3D texture of the object. You cannot use things by feeling.
In the game, the algorithm used should be called fake bump mapping, false concave and convex textures. In the game, bump map does not change the surface of an object, but only affects the result of illumination and deceives the eyes. The simplest way is to directly overlay the bump map on the rendered surface, resulting in brightness disturbance, which makes people think it is concave and convex-this is easy to understand, turning the skillful part of a white wall into a gray area will turn into an erosion mark, which you will be better at than a small one. Computing complexity is the basic addition and subtraction. This so-called fake bump mapping has been supported by hardware since geforce2, but it has never been widely used.
However, it is interesting that the bump map is never outdated. In later rendering algorithms, the features of storing the surface height domain still play a huge role. We will mention Normal mapping later.
2. Normal mapping
The practice of Normal mapping in the gaming field is a period worth remembering-the emergence of gefore3, the emergence of GPU concepts, the emergence of hardware programmable pipelines (shaders), and the emergence of Normal mapping, another name is dot3 bump mapping.
The texture used to implement its control is a texture called normal map, which is also discussed at present. Let's first talk about this figure called normal map. What is stored in this figure is the iteration of each original surface normal, which is a bit complicated but not hard to understand. For example, in the 3D model of a game, the surface normal is like a pen standing on the desktop, vertical up. What is stored in normal map is the direction that the pen that represents the normal direction of the surface "should" point to-for example, tilting to the left for 15 degrees.
Normal map has two main forms: normal map of the world space and normal map of the cut space. The first one has no practical value in the game. The second one is the most common one.
So why is the normal map so strange? In fact, normal map is the same as bump map, that is, the color displayed by it is not directly related to its role. You must be familiar with the concept of spatial coordinates. In the definition of normal map, there is a prior agreement, which is the vertical direction of the original surface, which is called the Z axis; and the UV coordinate of the surface in two directions, corresponds to the X and Y axes respectively. (To be exact, it should be called tangent and negative normal, but these two things just overlap with the UV coordinates that everyone is familiar with, so it is more common to everyone) then we know that if we take a point on the XYZ axis, the value of this point is between-1 and 1, then we can get a normal direction pointing to any direction (you do not need to explain more, we know that the normal is a vector, and the vector has two concepts: Direction and length, but for the normal, length is not required ). However, when we describe the color, the values of the three RGB channels start from scratch. However, when we try to save any normal in a texture, we will face the negative value problem. Therefore, we need to compress the normal. The method is simple. The normal projection length on each axis of XYZ is calculated by N + 1/2. In this way, all the normal values are compressed to the ranges of 0 and 1. Then we store XYZ in three RGB channels. It seems that we haven't talked about why normal
MAP is blue, right. Now is the time to announce the results! First, we know what the XYZ coordinate is if the normal is vertical up on the surface of an object? Is it 0, 0, 1? Then we compress the number according to the compression method we mentioned earlier. Add 1 to each number and divide it by 2. what we get is 0.5, 0.5, and 1, right? So we can import it to RGB, so we will get 128,128,255, right? Let's see the color in the palette!
P.s. Now fxcarl and you can guess a mystery and see if fxcarl is right. Now we can see a color on the normal map. The color is 219,128,219. Then the normal direction of the surface is vertical to the right 45 degrees. How can I use Max to make a normal map to see if fxcarl is right?
If you have not understood the meaning of normal map, or are interested in learning more about it, fxcarl will discuss it with you further. I don't know what everyone understands about the split space? Let's take an experiment and find three pens. Then, the two pens form a 90 degree mutual complement on the desktop, and the pen ends with the pen. Finally, We stacked the third Pen, pen tip up, pen end and the pen end on the two desktops on one point. Pay attention to our three pens! These three pens are the space coordinate of the point on the desktop! We must have thought that the direction of the surface normal stored in our normal map is originally a cut space vector. That's right, it's a cut space vector. But it seems that space cut is useless, doesn't it? We may wish to change the desktop to a basketball. Remember to maintain the relationship between the three pens, and then use the three pens together to touch the surface of the basketball. Oh, no? The advantage of the split space is that the coordinates in the cut space are valid on any surface! That is to say, the data in the shard space is irrelevant to the complexity of the 3D model! You can use it on any surface, even if the surface is still moving, it will not affect normal.
Map plays a role. Do you think this slice is useful?
Let's go back to the beginning and we will find out what kind of results will happen if we use the normal map of the world space? Hey, that would cause a very embarrassing result. For example, we made a normal map of a character, but there are two identical characters in our scenario, however, their positions and angles are different. So ...... My God ~ There must be a normal map of a character that cannot be applied! The normal map with the split space is no problem. Well, you can rest assured that the normal map made by Max or Maya is the normal map of the split space. The proof method is very simple ...... Check whether this texture is mainly composed of blue ......
OK. The following is the main story, which shows you how normal map works.
A prerequisite for using normal map-pixel-by-pixel coloring. For more information, see traditional coloring pages. Traditional Games use a simplified Phong lighting model, and even Games use the ground model. The two algorithms calculate illumination only for the vertex of the object 3D model, while the large area on the 3D surface is filled with difference value. Pixel-by-pixel coloring is available only after shaders appears. Therefore, normal ing is also a required Algorithm for shaders. The formula for calculating the diffuse reflection illumination of an object is simple ndotl-What is ndotl, which is the point product of the object's surface normal and illumination direction. Dot product is a problem of linear algebra. It is easy for art friends to write programs without further research: diffuse
= Saturate (MUL (normal, light ));. To put it simply, it is the projection of the direction vector of the light on the normal vector, and then the projection result becomes a value in the middle of the black and white. Let's also give a simple example. We put two pens on the desktop, and then one pen won't move, so that the end of a pen will be connected to the end of the first pen, and will not move, and then use the same pen tail as the center of the circle, move the pen. At this time, if we pull a line vertically (a vertical line) from the tip of a pen to the pen rod of another pen) then we can see the length of the moving pen projected by the original pen rod (that is, the pen tip of a pen connects the vertical line to the position on the pen of another pen, the length of the position along the pen bar to the end of the PEN) will get shorter and shorter. When the two pens are vertical, the projection result is zero-No illumination contribution. It is easy to understand that when the direction of the light is absolutely parallel to a surface, the surface will no longer accept the light. Now we introduce normalmap. In this case, the illumination calculation is a little different from the previous one. we replace the surface normal with the normal stored in normalmap. In this way, when we calculate the surface illumination, we will produce a much richer variation of light and shade due to the constant variation of the normal.
As for why do we feel the bumps? This is the way people lie to themselves ...... In fact, there is no concave or convex place, but our eyes are too nosy. Like what flat surface of Windows buttons, we thought it was convex.
Normal map seems to add details, but its disadvantages are also obvious. However, before talking about the disadvantages, we should say in advance that the advantage of normal map is far greater than that of normal map. Therefore, it is still an excellent thing. Do not be biased against it, especially before the more advanced technology we will introduce later. Do not. The biggest and most obvious drawback should be its perspective. Because normal map only changes the illumination of the surface, and does not change the shape of the surface. Therefore, it seems that as long as it is not close to the level, normalmap will not have a perspective problem. In fact, because normalmap cannot implement its own internal occlusion, it cannot show the ups and downs on the plane. For example, we highlight a piece on a desktop and then place a toothpick on the side of the highlight piece. If normal
Map performance. Based on experience, this bulge will easily block our sight and make us unable to see the toothpick. However, normal map does not. Therefore, we can always see what is behind the obstacle. This is a problem-that is, normalmap will play the best role only when it is perpendicular to the plane. In this way, normal map can only be used in situations where everyone is not sensitive to the occlusion relationship, such as scenes. Instead, it cannot be used for characters, but the characters using normal map cannot withstand close-up and zoom in, the drill angle is easy to help.
Although normal map has a huge problem that cannot be pinged, it is still far more advantageous than small obstacles, so it is worth promoting. The several emerging algorithms are actually developed by normal ing. Therefore, they are also of the most understandable value as the basis.
P.s. A secret about normal map. Understanding ...... In fact, normal map does not highlight the details of the high mode from the surface of the low mode, but rather concave the place where the high mode is lower than the highest point! Therefore, it is very accurate to reduce the number of modules. As you can imagine, we use a lower-die gypsum model that is slightly larger than the upper-die scale to engrave the upper die.
P.s. 2. as for the normal map method, the normal map method is not as convenient as Max when the normal map was first invented. Normal map is calculated from the bump map, therefore, a simple algorithm can be used to calculate the normal map from the bump map, or even on the fly (that is, the game engine can directly read bumpmap and convert it to normalmap ). Therefore, it is a better idea to draw bump for something that is very inefficient to build a model, but can significantly increase the surface details, such as particles on the cement surface, then let the technical artist fix it. Of course, you will use Z-bursh, so I will say nothing. Fxcarl estimates that the method of generating a line chart by Max is to compare the height offset of each vertex on the high and low modulus, and then generate a bumpmap for the height difference on each UV element, then change from bumpmap to normalmap.
3. Parallax ing parallax texture
(Because the subsequent algorithms are based on normalmap applications, they may not seem as long as normalmapping, but the content must be just as wonderful !)
Parallax Paster is an enhancement algorithm of the normalmapping algorithm, which is essentially no different from normalmapping. The advantage is that you only need to add 3 HLSL statements and a control texture channel (only a few GPU commands are required, and the cost is low to ignore) to significantly increase the depth of the object surface. However, the problems in normalmap basically occur in Parallax mapping-especially when the angle of view is close to parallelism, the sense of parallelism disappears, there is no significant improvement-in fact, the problems caused by using normalmap are as lingering as the problem of the visual angle of the LCD screen. Or, according to fxcarl, Parallax
Mapping is the normalmapping that truly has practical value.
It has proved that this technology is very suitable for new generation game hosts such as xbox360 and PS3 (both listed for one year and used the next generation ...... I can't take it anymore ). For example, the 360 game Sega death penalty criminal uses the same monolith engine as the pcgame fear-using Parallax mapping.
Parallax mapping uses a single control texture. A normalmap. If we use ACDSee to see this normalmap, we will find that it seems to be the same as the control texture used by normalmapping. If we open the alpha channel of this normalmap, we will find the xuanjicang in it. The original alpha channel stores bumpmap corresponding to this normalmap! (Heightmap is used to record the surface height with saturation)
Insert a theoretical course. When you read the text above, you will see a word that controls the texture. This word should be explained here. Understanding Texture Control makes it very important to become an artist of the new generation. Based on the years of experience in fine arts, the understanding of Texel (texture) must be an Alpha Channel with rbg3 colors that express transparency. But in the eyes of our Renderer and programmers, it is not what our art friends see. What they see is a 4-channel vector (which can be understood as a combination of four numbers ). The value ranges from 0 to 255. This space can be used to do more things-the most common is to record the physical details of the table. Why do we need to control the texture? Fxcarl heard a friend say this two days ago: I think normalmap has nothing to do with it. It was also drawn directly. In fact, this is true, but you must know that this idea is outdated. Because normalmap is not used for coloring, it is used for generating colors more realistically. The method of painting, static frame can certainly be infinitely good. But what should I do? How can we ensure that the final coloring result is correct under different illumination relationships? The only practice is to repeat each frame. How can we achieve the most effective re-painting? We need to tell our Renderer the repainting reference to help you do some simple work. This is the role of controlling texture-telling the Renderer what you want to change in real time. In fact, there is a large range of texture control, except for normalmap. For example, NVIDIA's demo used textures to store the color variation pattern of the object surface in the sun. Compressing what the artist wants to change in real time in the texture tells the Renderer that it is a very challenging job, and of course it will get even more amazing images. Please accept texture control. It is a useful tool for artists to turn an instant precise coloring into a universal coloring tool!
How does Parallax mapping increase normalmap. Let's start with the features of normalmap. Let's assume that a bulge is made on the normalmap surface. Then let's look at the angle. We will find that, in fact, this raised face is facing our line of sight ~ It will not disappear because of the gradual flattening of our perspective-this is obviously incorrect, and it is necessary to know what is behind it. Therefore, Parallax mapping is used to alleviate this problem. The specific code is not mentioned here. I will try to explain the principles in the vernacular. In fact, in order not to let us see what we shouldn't see, we should try to move the texture coordinates ...... Jump over the Texel that shouldn't be visible to the player. That is to say, based on the data provided by the height chart, the texture behind the texture at the lower position is pulled forward. This is equivalent to jumping over the theme deliberately during the Graphic Element sampling. In this way, the pixel that should not be seen by the player will disappear because of the disappearance of the graphic elements-obviously, this algorithm is not very robust, although it will refer to the player's line of sight in computing. But it is still an estimation from experience. It is gratifying that this improvement looks good for the minor details that normalmap needs to perform. Therefore, a large number of game decisions began to be adopted. In particular, it has the advantage that the cost is extremely limited, and the amount of work that needs to be increased is only for the artist to save the height map to the alpha channel. Very cost-effective.
However, for technical researchers, such performance is obviously not satisfactory. Therefore, along with the idea of parallax Paster, shadermodel3.0 is used. There is an algorithm for physically changing the surface of an object. This is the displacement ing we will introduce in the next article.
4. Displacement Mapping
Unlike the methods mentioned above, displacementmapping is a method that truly changes the surface of an object. A technique called micropolygons (micropolygons) Tessellate (MOSAIC) is used to truly change the surface details of an object.
The specific process is as follows. First, according to the screen resolution, the visible surface of the model is embedded with a micro-polygon with the same size as the final pixel. This process is called Mosaic. Then read a bump texture. Determine the height based on the gray scale of the surface. Then, move the polygon along the normal direction of the original surface based on the polygon obtained by the mosaic. Then we can determine the new normal direction for the new polygon. At this point, the surface of the object has indeed added details.
In fact, we can see this technique when using zbrush. When you use zbrush, you will know that the details on the surface will become clearer only when the screen is still. Micro-polygon mosaic plays a similar role. Only the rough surface details of the polygon facing the screen are enhanced, rather than the whole model. Therefore, the performance cost is not as high as that of direct upper mode. In comparison, the displacement Paster has no flaws in the effect, but it does not have any disadvantages.
First, hardware requirements are high. shadermode3.0 must be supported, because Sm3 can be used for texture operations at the vertex stage. At the same time, mosaic consumes a lot of performance. However, in terms of GPU pressure, it seems to be more reasonable (because of the higher requirements for vertex operations, the object-level operation requirements are not affected) certainly, it will be more valuable in the future dx10 uniform rendering architecture.
Compared with all the concave and convex pasters we have introduced, displacement pasters are the only way to change the geometric shape of a polygon surface. Compared with the light tracing algorithm to be introduced later, the performance consumption of this algorithm is not dominant, but it is actually more reasonable. It gives the screen more special effects. What's more interesting is that it does not conflict with other pixel-based concave and convex pasters. In fact, this displacement map can be seen in new generation host games. It may not be what you want.
It can be used to generate a large area of outdoor terrain in real time! This is incomparable to any other concave and convex pasters!
Reliefmapping and parallaxocclusionmappingAnd conemapping embossed texture maps and parallax blocking textures and cone tracking textures
Three advanced algorithms are used to track the light in the slice. The three methods are light tracing, beam tracing, and cone tracking. Of course, it can be said that the following are the first improvements. These are future-oriented technologies and promising. Reliefmapping can even implement complex geometric surfaces such as ring deduction, and it can solve the problem of not being able to face the problem!