Normal to a surface

Hi all,
I have some basic questions.

  1. Why normal is used for lighting. Is there any place where I can get information about selecting a normal for a surface to be used for lighting ?

  2. I have a set of points/vertices. I can guarantee that these are the verices of a plane. Is there any way to get normal with length 1.0 for plane with the n(defined) number of vertices ?

Thanks in advance
Deek**** M

There’s a lot of information online about computing the normal to a surface.

A surface normal is a vector perpendicular to the surface at a given point. It is used in computing the amount of light reflected off of a surface. The smaller the angle between the surface normal and the light ray normal, the brighter the surface will appear.

You can get a normal with length 1.0 by “normalizing” your surface normal.

suppose you have a surface normal defined by some x,y,z.

first you find the length of the surface normal: length = sqrt(xx+yy+z*z);
where x,y,z are the components of the surface normal.

then you divide each component of the surface normal vector by the length:

x /= length, y/=length, z/=length.

you can always call glEnable(GL_AUTO_NORMAL) and have OpenGL generate normals for you, but this won’t always give you the best results. If you’re a beginner to OpenGL i suggest just enabling GL_AUTO_NORMAL and getting familiar with more of the basics before worrying too much about generating your own normals.

Actaully I was planning to do a project on 3D home walkthrough. Where we construct house using rectangles and triangles (only). So, to enable proper lighting I need to set the normal properly. But I have the following doubt.

  1. How to calculate normal for a rectangle and a triangle.
    2)Do I need to specify normal for each vertex of the rectangle.