OpenGL gotcha: scale your normals!

My OpenGL blunder this evening involved forgetting to make sure my normals were scaled correctly.

I had a scene with a single point light source and several small rotating cubes. Everything looked fine. I had also written a function to draw a 1×1 plane in the scene, and that looked fine too. I then applied a scaling transformation in my plane-drawing function (using glScalef) to make it 10×10, but for some reason the plane was then totally dark.

I tried moving and rotating the plane to see if it would catch the light at some other angle, but it wouldn’t. Eventually, I spotted the flaw…

Read the rest of this entry »