Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Understanding glNormal3f

I can't understand the glNormal3f, I know that it works for 'normalize' the 'normals' of the vertex... Or something like that, but I can't understand what is the 'normal' of the vertex. Can you explain me that function? I can't understand what 'normal' means in openGL...

like image 724
Spamdark Avatar asked Oct 31 '12 00:10

Spamdark


2 Answers

The "normal" of a vertex is the vector which is "perpendicular" to the vertex. In mathematics "normal" is a generalization of "perpendicular". For a polygon, this "normal vector" is perpendicular to the polygon and is the same for all of its vertices. One reason you might assign different normal vectors to each vertex of a polygon is if you are covering a curved surface with very small triangles. In this case, you don't want the normal vectors of the three vertices of the triangle to all be the same.

Now what is this normal vector used for? The typical application is used for coloring calculations when lighting is enabled in OpenGL. The normal vector can determine whether the light from a light source hits a surface and what angle a light ray makes with the surface. This can then be used to determine whether the surface is shadowed or contains a specular highlight, for instance.

like image 58
Code-Apprentice Avatar answered Sep 28 '22 09:09

Code-Apprentice


A call to glNormal will emit the normal vector to the last emitted vertex. A vertex normal is usually calculated as the normalized average of normals of the faces incident to the vertex. The normals of faces are vector so that they are perpendicular to the plane described by the face.

This function is deprecated and you really should pick up a good/tutorial or book.

See also Vertex Normal and the associated entries.

If you should not use glVertex* and the associated glNormal* functions, what should you use? Shaders and VBO's. Have a look at this question.

like image 35
pmr Avatar answered Sep 28 '22 07:09

pmr