iDevGames Forums
CameraPosition + Lighting ?? - Printable Version

+- iDevGames Forums (http://www.idevgames.com/forums)
+-- Forum: Development Zone (/forum-3.html)
+--- Forum: Graphics & Audio Programming (/forum-9.html)
+--- Thread: CameraPosition + Lighting ?? (/thread-7357.html)



CameraPosition + Lighting ?? - <seb> - Feb 2, 2003 02:11 AM

hi!

i have a problem that seems to have sth to do with
my camera direction or lighting. my normals are all set
correctly, but when i move my camera direction up, my
polygons get brighter, when moving it down, they darken.

here are my lighting settings:
* * * * * * * * * * * * * * * * * *
float material_ambient[] = {1.0, 1.0, 1.0, 0.0};
float material_diffuse[] = {1.0, 1.0, 1.0, 0.0};
float material_specular[] = {1.0, 1.0, 0.0, 0.0};
float material_emission[] = {0.0, 0.0, 0.0, 0.0};

float ambient_light[] = {0.2, 0.2, 0.2, 0.0};

float light_ambient[] = {0.0, 0.0, 0.0, 0.0};
float light_diffuse[] = {1.0, 1.0, 1.0, 0.0};
float light_specular[] = {0.0, 0.0, 0.0, 0.0};

float light_pos[] = {0.0, 900.0, 0.0, 0.0};
float light_dir[] = {0.0, 100.0, 0.0, 0.0};

glColorMaterial(GL_FRONT, GL_AMBIENT_AND_DIFFUSE );
glMaterialfv(GL_FRONT, GL_EMISSION, material_emission );
glMaterialfv(GL_FRONT, GL_AMBIENT, material_ambient);
glMaterialfv(GL_FRONT, GL_DIFFUSE, material_diffuse);
glMaterialfv(GL_FRONT, GL_SPECULAR, material_specular);
glEnable(GL_COLOR_MATERIAL);

glLightModelfv ( GL_LIGHT_MODEL_AMBIENT, ambient_light );
glLightfv ( GL_LIGHT0, GL_POSITION, light_pos );
glLightfv ( GL_LIGHT0, GL_SPOT_DIRECTION , light_dir );
glLightfv ( GL_LIGHT0, GL_AMBIENT, light_ambient );
glLightfv ( GL_LIGHT0, GL_DIFFUSE, light_diffuse );
glLightfv ( GL_LIGHT0, GL_SPECULAR, light_specular );
glEnable (GL_LIGHT0);
glEnable (GL_LIGHTING);
* * * * * * * * * * * * * * * * * *



and this is how i position my camera:
* * * * * * * * * * * * * * * * * *
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();

gluLookAt(cam.position.x,
cam.position.y,
cam.position.z,
cam.position.x + cam.direction.x,
cam.position.y + cam.direction.y,
cam.position.z + cam.direction.z,
cam.upVector.x,
cam.upVector.y,
cam.upVector.z);
* * * * * * * * * * * * * * * * * *


does anybody have a clue why the camera-angle affects
the brightness of my polygons? any advice would be very
welcome Smile

cheers!
sebastian


CameraPosition + Lighting ?? - w_reade - Feb 2, 2003 09:57 AM

It's meant to.

Try making the material's specular colour black if you really don't want it.

[edit - since you asked why, basically:]

Ambient colour is applied to everything, regardless of where the polys or the lights are.

Diffuse colour is applied to every poly that faces the light, and will be brighter the closer to head-on to the light the poly is.

Specular colour is "highlight" colour - it's brightest when the light bounces off the polygon into the camera, and fades to nothingness as the poly, camera, or light moves so that the reflected light doesn't hit the camera.


CameraPosition + Lighting ?? - monteboyd - Feb 2, 2003 03:22 PM

I think maybe light direction is being transformed by your model view transformations. Try setting the light positions after setting the camera position. I'm not sure if this is the most efficient method but it should fix your problem.


CameraPosition + Lighting ?? - <seb> - Feb 3, 2003 03:10 AM

it does Smile
thank you very much!

seb