 # Averaging normals

I simply cannot get normal averaging to work. I was under the impression that normal averaging in triangle strips occurs automatically. glShadeModel = GL_SMOOTH, and that’s how it was explained to me.

I was thinking perhaps this is not something GL does automatically? If so, how do I average normals mathematically at an intersection of 2 or 4 vertices?

Here is my display-list for my object. If anyone has suggestions, please email efesar@nmia.com. Eternally grateful.

//////////////////////////////////////////////////////////////////
// MyGLbackplane()
// Our cyan backplane display list
//////////////////////////////////////////////////////////////////
void CMyGL::MyGLbackplane()
{
float specref[] = {1.0f,1.0f,1.0f,1.0f};
float amref[] = {0.5f,0.5f,0.5f,1.0f};

``````float ellX = 1.1f;
float ellY = 0.75f;

glNewList(backplane,GL_COMPILE);

glPushAttrib(GL_ENABLE_BIT );
glDisable(GL_CULL_FACE);

// set the material for our backplane
glMaterialfv(GL_FRONT_AND_BACK,GL_SPECULAR,specref);
glMateriali(GL_FRONT_AND_BACK,GL_SHININESS,64);
glMaterialfv(GL_FRONT_AND_BACK,GL_AMBIENT_AND_DIFFUSE,amref);

float jinc = 5.0f;

// a grid of 66x66 little quads (for specularity)
for (float ii=0.0f;ii &lt; 32.0f; ii++)
{
glBegin(GL_TRIANGLE_STRIP);
for (float jj=0.0f;jj&lt;=360.0f; jj=jj+jinc)
{
float v1,v2;
float out;

v1 = ellX*(float)cos( DegToRad(jj) ) * ii;
v1 = ellY*(float)sin( DegToRad(jj) ) * ii;
v1 = 100.0f -(float)cos( DegToRad(ii) ) * 100.0f;

v1 = ellX*(float)cos( DegToRad(jj+jinc) ) * (ii);
v1 = ellY*(float)sin( DegToRad(jj+jinc) ) * (ii);
v1 = 100.0f - (float)cos( DegToRad(ii) ) * 100.0f;

v1 = ellX*(float)cos( DegToRad(jj) ) * (ii+1.0f);
v1 = ellY*(float)sin( DegToRad(jj) ) * (ii+1.0f);
v1 = 100.0f - (float)cos( DegToRad(ii+1.0f) ) * 100.0f;

v2 = v1;
v2 = v1;
v2 = v1;

v2 = v1;
v2 = v1;
v2 = v1;

v2 = ellX*(float)cos( DegToRad(jj+jinc) ) * (ii+1.0f);
v2 = ellY*(float)sin( DegToRad(jj+jinc) ) * (ii+1.0f);
v2 = 100.0f - (float)cos( DegToRad(ii+1) ) * 100.0f;

CalcNormal(v1,out);

glColor3f(0.7647f,0.4353f,0.1059f);

glNormal3fv(out);
glVertex3fv(v1);

glNormal3fv(out);
glVertex3fv(v1);

glNormal3fv(out);
glVertex3fv(v1);

CalcNormal(v2,out);

glNormal3fv(out);
glVertex3fv(v2);

}
glEnd();
}

glPopAttrib();

glEndList();
``````

}

GL_SMOOTH tells OpenGL to interpolate between colors, it has nothing to do with normals. If you would use GL_FLAT instead you would get an constant color.

To get an average of the normalvectors you just need to add them together and normalize.

Pseudo:
AvarageNormal = (Normal1 + Normal2 + Normal3) / length(Normal1 + Normal2 + Normal3);