PDA

View Full Version : Lighting Problems

wpcmmx
08-01-2001, 11:51 PM
Hi, I hope some one can help me.

I have so many diferent solids draw, each one has been draw whit a diferent transformations( translate and rotate ), and i have define a light LIGHT0 but it applay diferent for each solid like if the light has been transformet whit the solid transformation.

I know light is in eyes coordinate but i can put it globaly.

How do I render those solid and makes the like to by apply equal for all, like a real world. ???

T2k
08-02-2001, 12:06 AM
semms that you transform the lightpos (this will be first transformed like a vertex, before the calculations take place in eye coords ...)
so 1st do place lights, then transform the rest of the scene to get 'global' lights and set the w value to 1.0 or you get directional lights ...

wpcmmx
08-02-2001, 08:27 AM
Thanks, it works i just put lightpos al init, but now when i move the camara, light behivore is like is is on board whit the carama, what i mean is that light not remains at ( 1, 1, 1, 1 ) is is allways lighting the object, i can go to the dark part moving the camara.

When i get this efect, is where light seems to be different for each object.

T2k
08-02-2001, 11:59 PM
try this, for setting cam:
glMatrixMode(GL_PROJECTION);
//Set cam, glTranslate is in this mode the negative like in modelview
glMatrixMode(GL_MODELVIEW);
//set other objects, they wount be magnituded to the cam
and dont forget glLoadIdentity(); after glMatrixMode, or you could get some errors

Deiussum
08-03-2001, 05:14 AM
That's not a good idea T2k. You shouldn't do glTranslate, etc. in the projection matrix. You could screw up calculations for things like fog.

Instead, what he should probably do is something like this...

DoCameraTransformations();
SetLightPos();
DoObjTransformations();
DrawObject();

Or maybe

SetLightPos();
DoCameraTransformations();
DoObjTransformations();
DrawObject();

I didn't quite understand what exactly was wanted, but experimentation with where you put the setting of the light position should fix the problem.

wpcmmx
08-03-2001, 10:34 AM
I have try both but, ligth stay allways on front of objects, or you can go to the dark part of one object but light for each object semms diferent, i mean is like the light has been transformed by the same transformaion tha was aplly to the object it is lighting.