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.
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.