Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

BigDaddyScat

OpenGL OpenGL lighting

This topic is 6770 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Making a 3d scene and for some reason it seems to be that my lights shine brighter toward the -z axis than +z and was wondering if there is some obvious problem with my implementation. Here is the light code for my scene. Scott Oldfield (oldfiesa@muohio.edu) GLfloat pos[] = {50, 10, -25, 1}; GLfloat pos1[] = {50, 10, 25, 1}; GLfloat pos2[] = {-40, 10, -20, 1}; GLfloat pos3[] = {-40, 10, 20, 1}; GLfloat spot_direction1[] = { 0, -1, 0}; GLfloat spot_direction2[] = { 0, -1, 0}; // light 0 glLightfv(GL_LIGHT0, GL_POSITION, pos); glLightfv(GL_LIGHT0, GL_SPECULAR, pDoc->specular); glLightfv(GL_LIGHT0, GL_DIFFUSE, pDoc->diffuse); glLightfv(GL_LIGHT0, GL_AMBIENT, pDoc->ambient); glLightf(GL_LIGHT0, GL_SPOT_CUTOFF, 180.0); glLightfv(GL_LIGHT0, GL_SPOT_DIRECTION, spot_direction2); // light 1 glLightfv(GL_LIGHT1, GL_POSITION, pos1); glLightfv(GL_LIGHT1, GL_SPECULAR, pDoc->specular); glLightfv(GL_LIGHT1, GL_DIFFUSE, pDoc->diffuse); glLightfv(GL_LIGHT1, GL_AMBIENT, pDoc->ambient); glLightf(GL_LIGHT1, GL_CONSTANT_ATTENUATION, 1.0); glLightf(GL_LIGHT1, GL_LINEAR_ATTENUATION, 0.0); glLightf(GL_LIGHT1, GL_QUADRATIC_ATTENUATION, 0.0); glLightf(GL_LIGHT1, GL_SPOT_CUTOFF, 180.0); glLightfv(GL_LIGHT1, GL_SPOT_DIRECTION, spot_direction1); glLightf(GL_LIGHT1, GL_SPOT_EXPONENT, 0.0); // light 2 glLightfv(GL_LIGHT2, GL_POSITION, pos2); glLightfv(GL_LIGHT2, GL_SPECULAR, pDoc->specular); glLightfv(GL_LIGHT2, GL_DIFFUSE, pDoc->diffuse); glLightfv(GL_LIGHT2, GL_AMBIENT, pDoc->ambient); glLightf(GL_LIGHT2, GL_CONSTANT_ATTENUATION, 1.0); glLightf(GL_LIGHT2, GL_LINEAR_ATTENUATION, 0.0); glLightf(GL_LIGHT2, GL_QUADRATIC_ATTENUATION, 0.0); glLightf(GL_LIGHT2, GL_SPOT_CUTOFF, 180.0); glLightfv(GL_LIGHT2, GL_SPOT_DIRECTION, spot_direction2); glLightf(GL_LIGHT2, GL_SPOT_EXPONENT, 0.0); // light 3 glLightfv(GL_LIGHT3, GL_POSITION, pos3); glLightfv(GL_LIGHT3, GL_SPECULAR, pDoc->specular); glLightfv(GL_LIGHT3, GL_DIFFUSE, pDoc->diffuse); glLightfv(GL_LIGHT3, GL_AMBIENT, pDoc->ambient); glLightf(GL_LIGHT3, GL_CONSTANT_ATTENUATION, 1.0); glLightf(GL_LIGHT3, GL_LINEAR_ATTENUATION, 0.0); glLightf(GL_LIGHT3, GL_QUADRATIC_ATTENUATION, 0.0); glLightf(GL_LIGHT3, GL_SPOT_CUTOFF, 180.0); glLightfv(GL_LIGHT3, GL_SPOT_DIRECTION, spot_direction1); glLightf(GL_LIGHT3, GL_SPOT_EXPONENT, 0.0);

Share this post


Link to post
Share on other sites
Advertisement
While I can see no obvious problem, I''m not a real guru, All I can ask is that are you doing any transformas/rotations that could induce gimble lock? hence it shining along a different axis in a different direction.

It''s just a thought....

-Mezz

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
are you doing camera transformations in the projection matrix? this will mess up lighting info. the inverses of the camera transformations need to go in the modelview matrix.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!