View Full Version : Normal to a surface

dmantamp

03-07-2004, 10:46 PM

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

Aeluned

03-08-2004, 10:06 AM

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(x*x+y*y+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.

dmantamp

03-09-2004, 08:07 PM

Hi,

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.

Powered by vBulletin® Version 4.2.5 Copyright © 2018 vBulletin Solutions Inc. All rights reserved.