View Full Version : Lighting/Normals help

05-24-2003, 08:07 AM
First, the problem: I calculate and normalize a set of normals for an object, then draw the object with these normals. Works great. However, as I zoom in on the body it becomes "washed out", i.e. completely white. Now, my first thought was, I must be screwing up GL_RESCALE_NORMALS - it's on, but not working. So that's my guess.

The question is, how? The code to set up my view is complicated and messy - I couldn't figure out a good way to keep the aspect ratio of the image correct, so I took the approach that worked. Here's what the code looks like:

glMatrixMode( GL_PROJECTION );
glMatrixMode( GL_MODELVIEW );

//Zoom factor
glScalef( m_fltZoom, m_fltZoom, m_fltZoom );

//Set up a cubic region of space, extended along the Z axis so that we don't get any clipping there...
glOrtho( -m_fltCubeDimension, m_fltCubeDimension,
-m_fltCubeDimension, m_fltCubeDimension,
-m_fltCubeDimension * m_fltZoom * 2, m_fltCubeDimension * m_fltZoom * 2 );

//Set up the correct aspect ratio...
if( intTempWidth > intTempHeight )
// Zoom
glScalef( ( float )intTempHeight / ( float )intTempWidth, 1, 1 );
else if( intTempHeight > intTempWidth )
// Zoom
glScalef( 1, ( float )intTempWidth / ( float )intTempHeight, 1 );

In the code, m_fltCubeDimension is the maximum dimension of my objects' bounding box. The width and height are of the viewport (in pixels).

So, my questions are: can anyone see how this would screw up my lighting? And, can anyone recommend a better approach to this viewing setup?