Jump to content
  • Advertisement
Sign in to follow this  
b34r

OpenGL gl_LightSource[].position weirdness

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

Hi, I'm must have overlooked something but it seems gl_LightSource[].position.xyz returns the light position transformed by the MODELVIEW matrix. In OpenGL if I'm not mistaken this MODELVIEW = ModelMatrix * CameraMatrix (or the other way around ymmv). Now, that may sound stupid but how am I supposed to use this position to make a point light? I cannot compute the diffuse term since the light is in camera space already (and model space but that's not a problem). My problem might come from the fact that I do not use Glut but my own set of matrice and that somehow GL expect to be able to split the MODELVIEW computation chain (?). I'm 100% sure my matrice are corrects, they're working fine in fixed OGL, DX and soft renderer... By providing the light position transformed by the camera to my shader I get the expected result but I'd rather use the uniform constants whenever possible. Could this be a Catalyst bug? ATi being the #1 crappy driver king that might not be surprising. Any idea?

Share this post


Link to post
Share on other sites
Advertisement
no, its completely correct :

Quote:
from http://www.mevis.de/~uwe/opengl/glLight.html
GL_POSITION
params contains four integer or floating-point values that specify the position of the light in homogeneous object coordinates. Both integer and floating-point values are mapped directly. Neither integer nor floating-point values are clamped.
The position is transformed by the modelview matrix when glLight is called (just as if it were a point), and it is stored in eye coordinates. If the w component of the position is 0.0, the light is treated as a directional source. Diffuse and specular lighting calculations take the light's direction, but not its actual position, into account, and attenuation is disabled. Otherwise, diffuse and specular lighting calculations are based on the actual location of the light in eye coordinates, and attenuation is enabled. The default position is (0,0,1,0); thus, the default light source is directional, parallel to, and in the direction of the -z axis.

Share this post


Link to post
Share on other sites
Thanks,

I must admit I didn't really know where to look at in order to get confirmation of this. So, how do they implement free point light in GL? I'm a little bit confused.

With one matrix (modelview), untransformed vertice and the light position in the modelview there is no way I see to make a point light...unless it is linked to the camera.

Right now I see how to do a directional light but that's the less useful light type \:... Well, I guess I'll use uniforms for now.
Thanks again.

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!