Lighting effect with culling backface

There are shadows in the lighting effect of the top graph, but there isn’t in the bottom one.

The code between the top graph and the bottom graph is that the GL_CULL_FACE is enabled in the bottom one. e.g.,
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);

The teapot and that object are rendered at the same time, in the same window, and with the same lighting conditions. However, the light effect of the teapot is pretty good in both conditions.

I don’t know what the problem is. It seems the backface triangles reslut in the difference of lighting effect.

The sample code of lighting is as follows:
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_COLOR_MATERIAL);
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);

glLightModeli(GL_LIGHT_MODEL_TWO_SIDE, GL_FALSE);
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, GL_TRUE);

float fPos[] = {0, 1, 0, 0.f};
glLightfv(GL_LIGHT0, GL_POSITION, fPos0);
glLightfv(GL_LIGHT0, GL_DIFFUSE, fDiffuse);


Lighting effect image
Thanks so much for any suggestion.

Since culling the back faces seems to fix the problem, it seems that drawing something in the top picture is wrong - you’re drawing the dark grey bits over the lighter bits. I’m assuming the light is shining onto the side of the front of the objects, so the darker patches could be the far side of the cloud. These faces would be back facing. So…

Did you enable depth testing? If you did not, you could be drawing the backs of the far side of the cloud over the near side of the cloud in the top picture. In the bottom, since these faces are backwards, they are not getting drawn and the picture looks correct.

Thanks so much for your reply.

I found the problem resulted from GL_POLYGON_OFFSET_FILL.
I enable it because I want to render polygon surface in FILL mode and LINE mode simutaneously. Although I only render in FILL mode in the picture, it seems GL_POLYGON_OFFSET_FILL should not used with lighting. I don’t know if it is a known issue, or maybe I just don’t know how to use it.

glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(2.0, 2.0);

I also find the larger the offset is, the worse the lighting effect will be.

Thanks again.