OpenGL CG Series Tutorials 06–normal Mapping (normal map) __shader

Source: Internet
Author: User

* Original articles, reproduced please indicate the source *

 

Open GL CG Series Tutorials 06–normal Mapping ( normal map )

 

Normal Mapping (normal mapping), whether in game development or other computer graphics development is a very wide range of technology. If the surface of an object is rough and uneven, the normal of the vertex of the object is heading in different directions, so the object looks uneven. To represent such an object, of course, you can use quite a few vertex data that contains different normals, and this is a very inefficient way to do so. This approach is clearly not applicable in interactive graphics programs that require high timeliness, such as games. In order to solve this problem, the concept of normal mapping is proposed.

Normal mapping is a normal texture map, but unlike a normal texture map, each pixel in the normal map holds the normal data. Normal maps are typically generated by a height map. Height diagram is a 8-bit grayscale, the darker the color represents the lower the height, the lighter the color represents the higher the height. As shown in Figure Fig1 (a) is a picture of the height generated by Photoshop. As you can see in Figure Fig1, a normal graph (b) is generated from the height diagram (a) and then affixed to the surface of the object (c), the lighter part represents the "convex" part of the object's surface, and the darker part of the height image represents the "concave" part of the object's surface

(a). Height map

(b). Normal diagram

(c). Applied to the surface of the object

Fig1. Height diagram and normal diagram

Let's take a look at how to generate normal graphs from a height. Using the data in the height map, two difference vectors (1, 0, HR–HG) and (0, 1, HA–HG)are computed, and the normals are equal to their outer product. Where Hg is the current pixel,Ha is a pixel above the current pixel, andHr is the right pixel of the current pixel. The relationship between them can be clearly seen from the figure Fig2 below.

Ha

Hg

Hr

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.