Jump to content
  • Advertisement

Archived

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

stefu

Directional light in OGL vs D3D

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

Finally I got my OpenGL lighting to work somehow in my GFX wrapper (supports OGL and D3D). This is fun: In OpenGL I must set light direction to point opposite direction than in D3D. Why? I can do it so but it bothers me if I don''t know why. In D3D I do all right, there''s no question about it I think the OpenGL lighting system is a bit of mystery. The light must be set every frame after view matrix is set by camera to make light fixed in scene.

Share this post


Link to post
Share on other sites
Advertisement
The Z axis is pointing in the opposite direction in OpenGL than the D3D default. This could explain why you have set the light in the "opposite" direction.

The light position is transformed by the contents of the current top of the ModelView matrix stack when you specify the light position with a call to glLightfv(GL_LIGHT_POSITION,…). You may or may not have to set the light position each frame depending on what you want the light be fixed to.
The OpenGL FAQ has a good discussion about this
http://www.frii.com/~martz/oglfaq/lights.htm#ligh0050

As far as I know is OpenGL and D3D lights identical.

Share this post


Link to post
Share on other sites
This is one I never understood. They say that OGL uses right-handed and D3D left-handed coord system. For OGL it is true, but I use right-handed coord system also in D3D. So Z -axis points towards me out of the monitor in both APIs. and X goes right and y up. In D3DX there are functions for bot LH and RH and I never had to change any vertex or normal data before so I don''t think that''s the problem.

If the Z was pointing opposite direction, I think it should be enought to change z-value of direction vector. (?) But I have to multiply (x,y,z) by -1.

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!