Normal vector of OpenGL learning notes

Source: Internet
Author: User



Places to be aware of:

1. Use the gltranslate* function or the glrotate* function to change the appearance of the object, but the normal vector does not change with it. However, using the glscale* function, varying degrees of scaling for each axis, is likely to lead to incorrect normal vectors, although OpenGL provides some steps to correct the problem, but it also brings a variety of overhead. Therefore, the use of the glscale* function should be avoided wherever normal vectors are used. Even if used, it is best to ensure that the axes are scaled proportionally.

2. Another place is that you can only define a normal vector for vertices or polygons, and you cannot define vertices for each specified place in the polygon (which may be misunderstood by the beginner, which is clearly stated in the Red Book);

Normal vector Description:

According to the Law of Light's reflection, the direction of Light's exit is obtained by the incident direction of light and the normal of entry. Therefore, for the specified object, after the light source is specified, the direction of reflection of the light can be calculated, and then the picture of the illumination effect is calculated. In OpenGL, the direction of the normals is represented by a vector.
Unfortunately, OpenGL does not calculate the normals of each point on the surface of the object that the polygons comprise, based on the vertices of the polygon you specify (which sounds confusing), and in general, in order to achieve the illumination effect, you need to specify its normal vector in code for each vertex.
You specify a normal vector in a way that is similar to the way you specify a color. When you specify a color, you only need to specify the color of each vertex, and OpenGL can calculate the color of other points between vertices on its own. Also, once the color is specified, all vertices specified later will be used as their own color, unless a new color is specified. When you specify a normal vector, you only need to specify the normal vector for each vertex, and OpenGL calculates the normal vectors of other points between the vertices themselves. Also, once the normal vector is specified, all vertices specified later will be used as their normal vector, unless a new normal vector is specified. You can specify a color using the glcolor* function, and you can specify a normal vector using the glnormal* function.

Normal vector of OpenGL learning notes

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.