Wrong Normal calculation!

I try to render a polygon with lighting enable. So as expected, the result will be a shaded polygon. But if I render a polygon with calling glScaled(-1.0,1.0,1.0);, at this time, no more shaded effect and even you change the normal direction.

Can anyone show me how to solve this problem. Thanks.

I believe that if you flip the x-axis, you should be able to flip the x-coordinate of your normal and get the same result as with an “unflipped” x-axis. However, I have not tried this myself. So, you should flip all the normal coordinates, just the x-coordinate.

When you have that scale on the modelview everything will be transformed through it correctly including the normals, HOWEVER, the light is positioned when you specify the position parameters. This means that the position will be scaled, only if positioned after you call glScale.

There are many lighting situations where a surface will appear unlit because of the result of the lighting calculation.

Originally posted by dorbie:
[b] When you have that scale on the modelview everything will be transformed through it correctly including the normals, HOWEVER, the light is positioned when you specify the position parameters. This means that the position will be scaled, only if positioned after you call glScale.

There are many lighting situations where a surface will appear unlit because of the result of the lighting calculation. [/b]
Exactly as what you say, if I call the Gl.glLightfv(Gl.GL_LIGHT0,Gl.GL_POSITION,position) after the glScale only one side of the polygon will appear lit and the other side will be unlit althought I
select the light model of ‘GL_LIGHT_MODEL_TWO_SIDE’. Do you know how to get rid of this problem? Thanks.

Are you using glEnable(GL_NORMALIZE) to ensure that normals are recomputed? It will cause bit performance hit but ensures that normals will be recalculated.
As normal needs to be multiplied with inverse transpose of the transform being applied to point (here scaling).

This is correct lighting, you need to add more light sources if you want both sides lit.

Two sided lighting automatically flips the surface-normal for all back faces as per the OpenGL specification. Only a normal facing the light source can be lit by the directional direct illumination in OpenGL.

You can do your own lighting by reversing face culling and keeping the same normals is you desire a different result. It will have less potential for hardware acceleration but two sided lighting with native acceleration that isn’t some slower multipass is a high end feature these days, so you may not be any slower afterall.