PDA

View Full Version : Scaling modelview matrix distorts directional light diffuse intensity



kevinfishburne
09-02-2012, 07:42 PM
I have an elevation dataset with elevation values of -32768 to 32767. I'm testing this dataset with smaller map sizes, so I need to scale the vertical axis so the map isn't insanely spikey. I did so by scaling the modelview matrix's vertical axis, which works great as it allows me to use values directly from the elevation dataset without manual scaling, which would be slower. I was scaling the projection matrix, but altered my code after discovering that was bad mojo.

I created a directional light, which I continually rotate on one axis to simulate the sun. I checked the vector visually and with atan2; works great. The problem is that the lower I set the diffuse values of the light and the greater the modelview matrix's scale the more the light "peaks" when shining directly down (noon) at the landscape. The closer the scale is to 1 the lesser the problem. The closer the diffuse values of the light are to 1 the lesser the problem. At extremes, noon looks light a lightning flash, to hopefully give you a better visualization.

Anyone know what the heck is going on? I'm glad I narrowed the problem down this far, but don't know how to go about scaling the light so it matches the scaled modelview matrix, or if that's even the solution.

mbentrup
09-02-2012, 10:30 PM
If you're using the fixed pipeline, call glEnable(GL_RESCALE_NORMAL).