I'm experiencing an odd problem where everything placed in front of my light appears black in my scene. This happens on multiple axes. I've searched the depths of the internet to find a solution, but I can't seem to find anything. It's also important to note that this is only happening to my models; the model's normals are fine and dandy. The rest of the scene renders as expected...

Here's how it looks: Flower

Here's how my light is initialized:

GLfloat light_ambient[] =
{ 0.2, 0.2, 0.2, 1.0 };
GLfloat light_diffuse[] =
{ 0.8, 0.8, 0.8, 1.0 };
GLfloat light_specular[] =
{ 1.0, 1.0, 1.0, 1.0 };
GLfloat light_position[] =
{ 15.0, 11.0, 10.0, 1.0 };

glLightfv(GL_LIGHT0, GL_AMBIENT, light_ambient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, light_diffuse);
glLightfv(GL_LIGHT0, GL_SPECULAR, light_specular);
glLightfv(GL_LIGHT0, GL_POSITION, light_position);



Here's how my light's position is set:

gluPerspective(60, (double)g_window1Width / g_window1Height, 1.0, 300.0);
glTranslated(0.0, 0.0, -player.camera.Dist);
glRotated(player.camera.Angle-90, 1.0, 0.0, 0.0);
glRotated(player.camera.Rot, 0.0, 0.0, 1.0);
glTranslated(-player.camera.TgtX, player.camera.TgtY, -player.camera.TgtZ);
glScaled(1.0, -1.0, 1.0);
glPolygonOffset(g_offset[0], g_offset[1]);

glClearColor(0.0, 0.0, 0.0, 0.0);

glm::vec4 light_position;
light_position.x = player.mouseMapPos.x - 1;
light_position.y = player.mouseMapPos.y - 1;
light_position.z = player.mouseMapPos.z + 0.5;
light_position.w = 1.0f;

glLightfv(GL_LIGHT0, GL_POSITION, glm::value_ptr(light_position));

I can supply more code and information as needed...

  • \$\begingroup\$ try decreasing attenuation. make the constant attenuation 0. \$\endgroup\$ Commented Nov 15, 2014 at 8:07
  • \$\begingroup\$ Changing the constant attenuation to 0 has the same result. The light creates a sort of hard line on the model. Depending on if the light is behind the object or not, it may not be lit at all. \$\endgroup\$
    – Sparky
    Commented Nov 15, 2014 at 16:21
  • \$\begingroup\$ I can't see your image. maybe due to our proxy, it doesnt let https through. if you have clamp issues maybe move to an HDR pipeline, or get in control of your light ranges. \$\endgroup\$
    – v.oddou
    Commented Nov 25, 2014 at 4:54

4 Answers 4


Your main issue is that you need to fix your normals. If you want to calculate smooth normals correctly please check my answers here and here. Also make sure that your normals are normalized.

Your second issue is your attenuation values, I often get better results with one attenuation type. So try to use one type of attenuation and try to modify its value until you get satisfactory results.

  • \$\begingroup\$ I've tried as you said. Previously smooth normals were being generated by Assimp, which is the model loading library I am using. I made a method to manually generate normals for the model from the links you provided. I also reset the attenuation values to default as you suggested. - I get the same result with slightly different lighting. I doubt if there's anything wrong with my normals, as I get the exact same result with normals pre-generated by blender. \$\endgroup\$
    – Sparky
    Commented Nov 25, 2014 at 23:54
  • \$\begingroup\$ @Sparky I understand, well, another point your light position is set at init time, this way it is being fixed in world space, if you want the light to be transformed you need to apply modelview matrix to it like other things, well remember that you are using old openGL which makes deducing what is happening exactly for light hard because of extensive use of global state. \$\endgroup\$
    – concept3d
    Commented Nov 26, 2014 at 6:03

The normals facing away from the camera are shaded black in your setup.

Add more lights into the scene that are shining on parts you want lit up, or set up the lighting with a brighter minimum brightness.

  • \$\begingroup\$ I adjusted the global ambient values, but it still behaves the same... \$\endgroup\$
    – Sparky
    Commented Nov 25, 2014 at 23:57

This should be a comment but I cant make them :(.

Anyhow it looks like a normals problem with your model. If you look at the bottom flower in the first picture the lighting is wrong and it looks like the light is coming from behind and above the flower instead of in front it. Try to set the color of each pixel to the value of normal to see if the normals are correct. I do not know how to do this with the fixed pipeline unfortunately.

  • \$\begingroup\$ I'm not sure there is a way to do this with a fixed pipeline. The light in this case is directly above the flower. What I mean by clamping is that everything beyond where the light is positioned on the y axis in my scene is shaded black, hence the hard line. \$\endgroup\$
    – Sparky
    Commented Nov 26, 2014 at 0:04

I'm not sure, but you probably should move code that sets color of light to update frame. As I understand you initialize light color only once at start of program, but it needs to be updated each frame, in accordance with this question.


You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .