Another one o' dem Lighting Probs
i''m also having problems with lighting, like most other people. i''m using 3d exploration, and when i light my scene, my meshes seem to be lit as if the light was attached to the object, so it''s always lit object-relative, not world-relative. where should i initialize my light, and place my lights? and should i define any of these in the main rendering loop? later on, i''m going to have the position of the lights change, but for now, i just want to get a light reflecting properly.
all materials are set.
using omnidirectional light.
using glut.
a2k
------------------General Equation, this is Private Function reporting for duty, sir!a2k
Are you resetting your light''s position every time the camera moves? If not, do so.
Morgan
Morgan
i should do this even when the position of the light doesn't change?
actually, what i have in my render loop is this:
//SET UP LIGHT 0
GLfloat mat_specular[] = {1, 1, 1, 1};
GLfloat mat_shininess[] = { 20.0 };
GLfloat light_position[] = { world->light.x, world->light.y, world->light.z, 1};
GLfloat white_light[] = {1,1,1,1};
GLfloat diffuse[] = {.9f, .9f, .9f, 1};
glMaterialfv (GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv (GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv (GL_LIGHT0, GL_POSITION, light_position);
glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv (GL_LIGHT0, GL_SPECULAR, white_light);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
a2k
Edited by - a2k on August 7, 2000 2:03:37 AM
actually, what i have in my render loop is this:
//SET UP LIGHT 0
GLfloat mat_specular[] = {1, 1, 1, 1};
GLfloat mat_shininess[] = { 20.0 };
GLfloat light_position[] = { world->light.x, world->light.y, world->light.z, 1};
GLfloat white_light[] = {1,1,1,1};
GLfloat diffuse[] = {.9f, .9f, .9f, 1};
glMaterialfv (GL_FRONT, GL_SPECULAR, mat_specular);
glMaterialfv (GL_FRONT, GL_SHININESS, mat_shininess);
glLightfv (GL_LIGHT0, GL_POSITION, light_position);
glLightfv (GL_LIGHT0, GL_DIFFUSE, diffuse);
glLightfv (GL_LIGHT0, GL_SPECULAR, white_light);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
a2k
Edited by - a2k on August 7, 2000 2:03:37 AM
------------------General Equation, this is Private Function reporting for duty, sir!a2k
yes though light position is the only one u need to set
// position viewmatrix/camera
GLfloat light_position[] = { world->light.x, world->light.y, world->light.z, 1};
glLightfv (GL_LIGHT0, GL_POSITION, light_position);
the rest u just setup in the init part
// position viewmatrix/camera
GLfloat light_position[] = { world->light.x, world->light.y, world->light.z, 1};
glLightfv (GL_LIGHT0, GL_POSITION, light_position);
the rest u just setup in the init part
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement