View Full Version : Weird Lighting-Problem
05-30-2002, 08:24 AM
I have added a light to my scene, but the lighting only works, if the light is located at 0,0,0....if i move my light, my objects just donīt get lit.
Why?? Shouldnīt the objects just get lit in a diffrent way?? But lighting just seems to be off...Please help!
05-30-2002, 03:05 PM
Make sure you call glLightfv(GL_LIGHT0, GL_POSITION, pos) every frame.
05-30-2002, 11:56 PM
Post the code where you are using the light for see it.
06-01-2002, 12:39 AM
Sorry, I canīt post the code...it would be too much and itīs in a lot of diffrent classes and functions etc.
But my problem even got more weird. When I look around in my scene, sometimes my objects ar lit correctly, but then, when camera has a special angle, the colors get changed and sometimes my whole scene is just drawn in black/white.....also my cursor gets white (before it was black). When I look back itīs black again and the other colors appear correctly
06-01-2002, 12:51 AM
This sounds completely whacked. You have some serious problems that could be the result of many things. Try simplifying things. Check your normals, check your light position values and watch where you apply it (hopefully after view transformation but before model transformation).
Some of your issues sound like you are positioning the light before the viewing matrix transformation has been loaded onto the modelview stack.
You need to understand the difference between positioning the light attached to the viewer, positioning the light in the scene and positioning it attached to an object. It all depends on what's on the modelview at the time.
06-01-2002, 01:08 AM
P.S. make sure that you are specifying the correct type of light with the fourth coordinate i.e. point light vs light vector. I assume you want a point source since you specify a position of 0,0,0. So you need to specify a position of 0,0,0,1 where the fourth coordinate w is one not zero. The one means you have a point light vs a directional (distant) light. Specifying a light position of 0,0,0,0 would be a very nasty thing to do and may explain many of your problems.
06-01-2002, 04:25 AM
Ah!!! That was it!!!!
I always called:
So i added a fourth coordinate with 1.0f and it works as it should!!! :-)
Maybe the arrays pointed some weird data...
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.