VC ++, OpenGL, SDL
I am wondering if there is a way to achieve smoother shading across one square of the geometry. Right now, the shading looks smooth with my spotlight, however the intensity rises along the diagonal unit [/] face. Lighting is basically an invisible intermediate vertex.



This is what happens when the light moves from left to right.
When I move the light on the surface, it does it sequentially. It turns brighter at each vertex and disappears from there.
Was I forced to break up the unit to achieve a smoother, more radial hue? or is there a method around this?
Here are the shaders that I use:
vert
varying vec3 vertex_light_position; varying vec3 vertex_normal; void main() { vertex_normal = normalize(gl_NormalMatrix * gl_Normal); vertex_light_position = normalize(gl_LightSource[0].position.xyz); gl_FrontColor = gl_Color; gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; }
fragmentation
varying vec3 vertex_light_position; varying vec3 vertex_normal; void main() { float diffuse_value = max(dot(vertex_normal, vertex_light_position), 0.0); gl_FragColor = gl_Color * diffuse_value; }
My geometry in case anyone wonders:
glBegin(GL_QUADS); glNormal3f(0.0f, 0.0f, 1.0f); glTexCoord2f(0.0f, 1.0f); glVertex3f(pos_x, pos_y - size_y, depth); glTexCoord2f(1.0f, 1.0f); glVertex3f(pos_x + size_x, pos_y - size_y, depth); glTexCoord2f(1.0f, 0.0f); glVertex3f(pos_x + size_x, pos_y, depth); glTexCoord2f(0.0f, 0.0f); glVertex3f(pos_x, pos_y, depth); glEnd();