View Full Version : Normals

12-13-2002, 10:43 AM
I used NeHe's tutorial on creating normals and I used something like:
glNormal3f( 1.0f, 0.0f, 0.0f );
glTexCoord2f( 10.0f, 10.0f );glVertex3f( 4.2f, 0.5f, -2.1f );
glTexCoord2f( 0.0f, 10.0f );glVertex3f( 4.2f, 0.5f, 1.0f );
glTexCoord2f( 0.0f, 0.0f );glVertex3f( 4.2f, 0.0f, 1.0f );
glTexCoord2f( 10.0f, 0.0f );glVertex3f( 4.2f, 0.0f, -2.1f );

to create a normal facing in the positive x direction. My question the values that go into glNormals( ) parameters. Is it ok to use 1.0 for any sized polygon?

12-13-2002, 10:56 AM
The normal has nothing to do with the size of the polygon, only the direction it's facing.

12-13-2002, 11:33 AM
so it doesn't matter what value you put inside the glNormas( )? Just as long as it's from -1.0 to 1.0 and in the proper direction to face.

12-13-2002, 12:06 PM
All normals if they are supposed to be used
by OpenGL HAVE to be at 1.0 ('unit') length. You can achive it in two ways:
1: tell OpenGL to normalize them before use
(glEnable(GL_NORMALIZE) http://www.opengl.org/discussion_boards/ubb/wink.gif
or 2: calculate them: length = sqrt(x^2 + y^2 + z^2);
if (length != 0) {
x /= length;
y /= length;
z /= length;
where x, y ,z are normal vector coordinates (stuff you put into glNormal3f(...))