Jump to content
  • Advertisement
Sign in to follow this  
gcmonk

OpenGL more light problems

This topic is 4818 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

More OpenGL lighting problems. My lighting doesn't seem to be moving now. It stays the same when I move around, which is basically doing a translate in the x or y direction when I press on the directional keys. The problem arises when I do a rotate in the Y-axis. glRotatef(mAngle, 0.0f, 1.0f, 0.0f); The shadows change for some reason. I made some screenshots to show what happens.

This is basically a simple heightfield terrain. I use triangle strips to create the terrain. What could cause the shadow to change?

Share this post


Link to post
Share on other sites
Advertisement
I can't stop thinking about this problem since I fell asleep (which can also be a problem when I'm currently at work). Anyway, my current reasoning as to what's wrong is the normal. Is there a difference whether the normal is say going out from the FRONT face or going out from the BACK face? I think I may have my normal's in the wrong direction and when I turn a certain way, the angle of the light rays to the normal is greater than 180 degrees and OpenGL will think these polygons shouldn't be lit...??? Bah, still don't get it...

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
....... it was a typo... blahhhhh

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
The problem is OpenGL's lighting system is intimately linked with the ModelView matrix. You can not separate them. You either do not use OpenGL lighting. Or you must perform transformations at the vertex level before submission to the pipeline. Or you could come up with complex inverse transformations to adjust for rotations by adapting the light position. This would involve a multiplication of the inverse rotation matrix against the light position vector then applying the light position update after the translations on your object. Either way, by the time you've gone through all this headache and with the limitations of the OpenGL lighting system in general, my verdict is to never use OpenGL lighting.

Either use your own per-vertex lighting calculations or use per-pixel effects with shaders, dot env combiners, or however you prefer. Lastly, if light/dark mapping is possible that is also an option.

I am currently working on a full production title and ran into this problem. I wish OpenGL used Direct3D's style of lighting.

PS - Don't try fooling with the order either. It just can't be done. I've tried every combination.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!