Textured quad not receiving light

Hello again. I am creating a spotlight centered in the viewport where 2 texture quads are rendered. As the image shows, only the red cursor is getting the light. I have no idea why the checkerboard isn’t receiving the light. They are both rendered the same way.


Here is the code I use to setup the light (I am still experimenting so please correct me if I’m doing something wrong):

		GLfloat position[] = { ViewWidth / 2.0f, ViewHeight / 2.0f, 100.0, 1.0f };
		GLfloat direction[] = { 0.0, 0.0, -1.0f };
		GLfloat color[] = { 1.0f, 1.0f, 1.0f, 1.0f };

		glLightfv(GL_LIGHT0, GL_POSITION, position);
		glLightfv(GL_LIGHT0, GL_AMBIENT, color);
		glLightfv(GL_LIGHT0, GL_DIFFUSE, color);
		glLightfv(GL_LIGHT0, GL_SPECULAR, color);
		glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, direction);
		glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 60.0f);
		glLightf(GL_LIGHT0, GL_SPOT_EXPONENT, 12.0f);

The viewport is orthographic if it matters. So any ideas what’s going wrong here?

Make sure the normals for the 2 quads are both pointing in the same direction.

I use the same code the render both quads:


			glNormal3f(0.0, 0.0, 1.0f);

			glTexCoord2f(0.0, 1.0f);
			glVertex2f((float)x, (float)y + (float)Height);

			glTexCoord2f(0.0, 0.0);
			glVertex2f((float)x, (float)y);

			glTexCoord2f(1.0f, 0.0f);
			glVertex2f((float)x + (float)Width, (float)y);

			glTexCoord2f(1.0f, 1.0);
			glVertex2f(x + (float)Width, y + (float)Height);


If you are using lighting with fixed function, the amount of light contributing to the scene will be calculated per-vertex + will be interpolated between the vertices. This means if you have a large plane with the light in the middle of it, each vertex will be far from the light so the lighting calculation at those vertices will be calculated as appearing poorly lit. Since the entire plane will be interpolating between these equally dark values far from the light, the middle will also appear dark.

To solve it, you could:

a) Continue using per-vertex lighting, but add more vertices/triangles, eg. Making the board from 8x8x2 triangles instead of 2 triangles will mean interpolation will be closer to what you expected, as there will be vertices close to the light if the light is in the middle of the board

b) Use per-pixel lighting via shaders instead of per-vertex lighting

I see. Thanks very much!