[HOpenGL] Confused about normals

Glynn Clements glynn.clements at virgin.net
Tue Oct 14 02:24:40 EDT 2003


Patrick Scheibe wrote:

> But now I am a little bit confused. I'm sure to heard about that if you 
> specify the vertexes of a polygon (with glBegin GL_POLYGON in c)
> counterclockwise then the normalvector is set automatically.
> That means if you look at a plane the normal vector points to you.
> 
> Is'nt that true?

No, it isn't.

Some of the higher-level operations (e.g. evaluators, NURBS, quadrics)
can optionally auto-generate normals, but this isn't the case for the
basic rendering primitives (glBegin/glEnd).

In fact, this can't be implemented, because the normal has to be
specified prior to each glVertex call, but you don't know the face
normal until you've specified at least three vertices. Furthermore,
computing the face normal is only useful if you want "flat" shading,
which often isn't the case.

> My example problem seems to show that this is definitly not true. So if I want 
> to use light (and that will be very often) and I have to specify these 
> vectors by myself then I can't use the renderPrimitive Polygon or Quad in 
> situ because the calculation of a normal vector of a polygon isnt that 
> trivial.
> The simplest way I see is to reduce this calculation to a normal vector 
> calculation of a triangle. So I'm forced to define a new function 
> makePoly taking a list of Points, calculating the normal and draw a polygon 
> with this points. Otherwise I have to write down some points more then one 
> time, the first time in the makenormal-function and in the secont at the 
> render call.
> 
> 1. Is this the way?

Yes; OpenGL doesn't do this for you so, one way or another, you have
to do it yourself.

> 2. Where is it used that normals aren't right-angeled to the polygon-plan?

It's often the case that a polygon mesh is just a sampling of a smooth
surface. In such cases, the normal is a property of the vertex, not
the face. I.e. where a vertex is common to multiple faces, the vertex
has a single normal; for any given face, each vertex will typically
have a different normal.

> 3. Exists there some higher-level function.

No.

-- 
Glynn Clements <glynn.clements at virgin.net>


More information about the HOpenGL mailing list