Question

If you look at this picture:

enter image description here

You can see that the left and right walls are brighter than the others, along with the faces of the chair. I was wondering, is this an issue with the normals? Or would it potentially be just the position of the light illuminating these surfaces?

In my main method I just do this:

//enable lighting
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);

//setup lighting
float lightColor [] = {1.0f, 0.8f, 0.8f,1.0f};

glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, lightColor);
GLfloat lightpos[] = {2,2,4,4};
glLightfv(GL_LIGHT0,GL_POSITION, lightpos);

If you need to see the normals I can upload it but I'm not sure if it is a problem with them or not.

Was it helpful?

Solution

It seems your normals are not computed as they should. Notice how same direction sides of different objects are lit differently.

I would guess that:

  • you are not transforming the normals right when transforming your objects;
  • your normals are not normalized to unit length (do you have glEnable(GL_NORMALIZE) in your code?)
  • normals computation is wrong in some other way (e.g. you round the values before sending them to render).

It is hard to suggest more possible causes without seeing your actual code.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top