PDA

View Full Version : Light behind image plane not working?



JayRay
06-28-2010, 01:12 PM
Hello,

I have a problem with my OpenGL lighting.

I use gluPerspective() and gluLookAt() to position my camera. Then I position my light. When I move and rotate the camera, the light basically works well while it is in front of the image plane. When I move the camera so that the relative light position exceeds the interval of +-90 degrees from the viewing direction, it appears to change its position to somewhere entirely different (I don't know where, probably quite far away, as I only see specular and ambient effects but no diffusion). Or, in other words, if the light position is behind the image plane, it switches its position.

I'm not using unsigned floats anywhere and the light position appears to work fine as long as it's in front of the image plane.

On a different note, I'm also confused by the fact that I'm observing specular effects at all, as I've initialized the light with:

specularLight[0] = specularLight[1] = specularLight[2] = 0.0f; specularLight[3] = 1.0f;

This however is a minor problem if at all.

I'm using GL_LIGHT0 exclusively, the OS is Windows XP, the IDE is Dev C++, graphics card is GeForce 9300M GS, OpenGL version 2.1.

Any help would be most appreciated.

Thanks for your time,

Jay

Edit: I would also like to point out that I did some web searching on this topic, but the keywords that I would associate with this problem didn't yield any related results.

JayRay
07-06-2010, 03:12 PM
Hello again,

I don't mean to annoy anybody with my problem, but does nobody have any suggestions or ideas about it? Perhaps just an idea what might cause it?

Anything would be greatly appreciated.

Thanks very much again.

ZbuffeR
07-06-2010, 04:29 PM
Sounds all very confused.
Specular at 0 should work.
Show the shortest code that still demonstrate your problems.

JayRay
07-08-2010, 05:36 AM
Hi,

thanks for your reply ZbuffeR.

I've actually just solved my problem. Turns out I forgot to switch to GL_PROJECTION before applying gluPerspective() and gluLookAt(). I was working on GL_MODELVIEW all along.

Maybe this can help somebody else, though for some strange reason it seems that actually nobody else has ever had this problem, as far as I could see.

Anyway; thanks again!

Regards,
Jay