Original Post
Normalizing normals should be a pretty simple issue, I am calling this code in my model loading routine: u, v, w are members of the vertex struct - they are the normal's x, y, z. But the strange thing is, it does not seem to be working. The lighting is excessively bright, which indicates that the normals are more in length than 1.0 unit. If I enable GL_NORMALIZE, the lighting is fine ... but I can't figure out what is wrong with the above code! I'm sorry that this is a stupid question, but it's really frustrating and I also don't want to call a GL_NORMALIZE every frame. So what should I do? [Edited by - deavik on September 17, 2005 9:38:28 PM]
// now normalize vertex normals
for (int i=0; i < mdl.n_vert; i++)
{
float _u = mdl.v_list.u;
float _v = mdl.v_list.v;
float _w = mdl.v_list.w;
float _length = sqrt(_u*_u + _v*_v + _w*_w);
mdl.v_list.u = _u /_length;
mdl.v_list.v = _v /_length;
mdl.v_list.w = _w /_length;
}
With GL_NORMALIZE
Without GL_NORMALIZE