Hello guys i have been reading on this forum for ages now but i would like to ask my first question.
I have a 3d scene which i am trying to light up. I have set up my positional light but the problem is when i enable lighting the scene goes extremely dark. You can only just make out that areas are lit. What i want is a scene that when lit most places look like they would with no lighting. I hope this makes sense. I have included a part of my code that deals with the lighting. I hope you guys can help.
I have set normals for the flat ground to be (0,1,0) and for a simple cuboid with the correct normals.
// called in my init function
glLightModeli(GL_LIGHT_MODEL_LOCAL_VIEWER, 1);
glLightfv(GL_LIGHT0,GL_AMBIENT,LightAmbient);
glLightfv(GL_LIGHT0, GL_DIFFUSE, LightDiffuse);
glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION,0.1);
glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
// In the callback function as eventually i would like the light to move
glLightfv(GL_LIGHT0, GL_POSITION, LightPosition);
Depending on what you are trying to accomplish, I believe you have to set up materials for your objects for lighting to work correctly. Normals will also have to be calculated for each object. Check out chpt 5 in the redbook for basic lighting examples.
your light is not so close, and depending on your object size it’s even quite far.
comment the 2 lines
//glLightf(GL_LIGHT0, GL_CONSTANT_ATTENUATION,0.1);
//glLightf(GL_LIGHT0, GL_LINEAR_ATTENUATION, 0.05);
and try again.
also check that your camera looks is the right direction