# Lighting and the backside

Is it possible to have the back of a quad lit as well as the front? i have a 3d mathematical formula, and part of it is lit on one side, and another part is lit on the other side. can i light both sides of both parts? thanks in advance.

yes, I believe you just call
glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);
this may cause a significant performance hit

after i look at it, it seems that both sides are shaded on one side, and neither are shaded on the other. i think the unshaded side is in the negative x, so maybe it has something to do with the crossproduct formula for normals? anyone have any idea?

a little code for ya eh?

``````glBegin(GL_QUADS);

for(x=-SIZE;x<=SIZE;x+=FREQ) {
for(y=-SIZE;y<=SIZE;y+=FREQ) {

pts.x = x;
pts.y = y;
z=sin(pts.x)+sin(pts.y);
pts.z = z;

pts.x = x+FREQ;
pts.y = y;
z=sin(pts.x)+sin(pts.y);
pts.z = z;

pts.x = x+FREQ;
pts.y = y+FREQ;
z=sin(pts.x)+sin(pts.y);
pts.z = z;

pts.x = x;
pts.y = y+FREQ;
z=sin(pts.x)+sin(pts.y);
pts.z = z;
``````
``````     normal.x=(pts.y-pts.y)*(pts.z-pts.z)-(pts.z-pts.z)*(pts.y-pts.y);
normal.y=(pts.z-pts.z)*(pts.x-pts.x)-(pts.x-pts.x)*(pts.z-pts.z);
normal.z=(pts.x-pts.x)*(pts.y-pts.y)-(pts.y-pts.y)*(pts.x-pts.x);
``````
``````     glNormal3f(normal.x, normal.y, normal.z);
glVertex3f(pts.x, pts.y, pts.z);
glVertex3f(pts.x, pts.y, pts.z);
glVertex3f(pts.x, pts.y, pts.z);
glVertex3f(pts.x, pts.y, pts.z);
``````
``````   }

}

glEnd();
``````