Two sided lighting won't work

I drew this truncated isocohedron where only pentagons are faces, everything else is just wireframe. Now I want these polygons to be lit from both sides by different light sources. This is what I’ve done:


  GL11.glLightModeli (GL11.GL_LIGHT_MODEL_TWO_SIDE, 17);
  FloatBuffer position1 = BufferUtils.createFloatBuffer (4).put (new float[] {0, 0, 0, 1});
  position1.flip ();
  GL11.glLight (GL11.GL_LIGHT0, GL11.GL_POSITION, position1);
  GL11.glColorMaterial (GL11.GL_FRONT_AND_BACK, GL11.GL_DIFFUSE);
  GL11.glColor3d (0, 1, 1);
  normale = normale (2 + fi, 2 * fi, 1,
                     2, 1 + 2 * fi, fi,
                     1, 3 * fi, 0);
  GL11.glNormal3d (normale[0], normale[1], normale[2]);
  GL11.glBegin (GL11.GL_POLYGON);
    GL11.glVertex3d (1, 3 * fi, 0);
    GL11.glVertex3d (2, 1 + 2 * fi, fi);
    GL11.glVertex3d (2 + fi, 2 * fi, 1);
    GL11.glVertex3d (2 + fi, 2 * fi, -1);
    GL11.glVertex3d (2, 1 + 2 * fi, -fi);
  GL11.glEnd ();

By the way, it is in Java :slight_smile: I only show how I draw a single polygon of my football, the lighting source is at the center of it. Every one of two polygons that are on opposite sides are lit incorrectly. For instance the mirror image of this polygon on X axis is lit how it should be. This one, on the other hand, has his outer side visible, not inner. I know the order of vertices is different in my program, that’s why I specify normal vector for each polygon. I checked, these vectors are calculated correctly.

What am I doing wrong?

The thing that stands out is the 17 in
GL11.glLightModeli (GL11.GL_LIGHT_MODEL_TWO_SIDE, 17);
I know that the specification says if this is 0, 2 sided lighting is disabled and for any other value it is enabled, but try to give it 1 or TRUE.

Tried it, didn’t work too… I noticed, that the problem is solved if I point the normal vector the other way or change the order vertices are listed. Yet, I don’t get why… If I choose to use two side lighting model and set same material properties for both sides what difference does a normal vector direction make?.. Why does it matter which is the front face? And why changing the order of how vertices are listed makes a difference if the normal vector is set?

Astounding discovery - Z axis is pointing away from me, not towards me. And I even have a book that says otherwise. Since my model is symmetric I didn’t notice it earlier. This explains why my normals where pointing the wrong direction, but why it is enough to change the order of the way vertices are listed? I always thought it only determines normal vector direction when I don’t specify it myself…

GL uses the polygon orientation to know if the polygon is front facing or back facing with respect to the screen.
If it is back facing, it flips the normal and does the lighting calculations.
Your normals must be in the right direction.

Also, you seem to be under the impression that GL computes normals if you don’t specify it yourself. It does not. It uses the last normal it has in memory.