I just can’t figure this out. This is part of a college project (and as such I’m reluctant to hand out full source because plagiarism filters pick up enough false positives as it is) and my lighting just isn’t working as expected. Rather than smoothly fading from diffuse + ambient to ambient, it’s snapping one to the other with no fade.
This is how I’m setting up my light:
glEnable( GL_DEPTH_TEST );
glEnable( GL_LIGHTING );
glEnable( GL_LIGHT0 );
glEnable( GL_NORMALIZE );
float fLightPos[4] = {0, 8, 0,1.0};
glLightfv( GL_LIGHT0, GL_POSITION, fLightPos );
glLightf( GL_LIGHT0, GL_CONSTANT_ATTENUATION, 1 ); //We don't want any falloff
glLightf( GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.0025 );
glLightf( GL_LIGHT0, GL_QUADRATIC_ATTENUATION, 0.0025 );
float fMaterial[ 4 ] = { 1, 1, 1, 1 };
float fMaterialb[ 4 ] = { 0, 0, 0, 1 };
glMaterialfv( GL_FRONT, GL_AMBIENT_AND_DIFFUSE, fMaterial );
glMaterialfv( GL_FRONT, GL_SPECULAR, fMaterial );
glEnable( GL_COLOR_MATERIAL );
glLightfv( GL_LIGHT0, GL_DIFFUSE, fMaterial );
glLightfv( GL_LIGHT0, GL_SPECULAR, fMaterial );
glLightfv( GL_LIGHT0, GL_AMBIENT, fMaterialb );
I’m fairly certain my normals are good. Printing them out, they are all unit. No scaling is occuring, just translation and rotation. And GL_NORMALIZE is set beforehand anyway. If I apply a per-pixel GLSL shader, the lighting does blend but only across the width of a triangle. Basically, the same problem, but better interpolated.
Any ideas before I say it’s cartoon shading and I meant to do it? I’ve spent a week trying to make this work and it just won’t.