Jump to content

  • Log In with Google      Sign In   
  • Create Account

We're offering banner ads on our site from just $5!

1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


Directional light in OGL vs D3D


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 stefu   Members   -  Reputation: 120

Like
Likes
Like

Posted 17 July 2001 - 02:21 AM

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.

Sponsor:

#2 Obelix   Members   -  Reputation: 122

Like
Likes
Like

Posted 17 July 2001 - 04:46 AM

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.

#3 stefu   Members   -  Reputation: 120

Like
Likes
Like

Posted 17 July 2001 - 05:42 AM

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.





Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS