Archived

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

OpenGL Light problem

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

Well, i set up a light in opengl, and i have a textured cube in the scene, and the cube rotates and stuff, but the weird thing in all of this is that the cube gets darker or brighter according to how much it is rotated. There is something weird with this, the object gets brighter when it is rotated to a certain degree... Well, i just thought some of you had seen, or experienced a similar behaviour, and how did you fix it? This is obvious an "ignorance" bug, where the programmer still does not know enough about the API, and stumbles upon behaviours that he sees as weird, althought they can easily be explained... Thanx for any help on this,

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Umm?? The light depends on the direction the polygon face is pointing (also known as, the normal). If the face is pointing towards the light, then it''s bright, if it''s not, then it''s darker. Think of you shining a flash-light on a Block. Now, take that block, and rotate it to the left.. you notice that not as much light is reflecting off the surface back to you.. so it appears darker. This is how a light works :o). So, it''s dependent on the angle the polygons face is to the light and how close/intense the light is. (As well as other factors like material types, etc, etc... but for now, that''s good enough).

Billy - BillyB@mrsnj.com

Share this post


Link to post
Share on other sites
ok, i think i expressed myself really bad...
i know normals and all of that, what happening here,
is that the object becomes more iluminated once it is
set into a certain degree.

Its like you''re standing next to a light bulb, but you''re
only iluminated when you''re seated, which makes zero sense...

I can only see the object when it is rotated to a certain
degree, only then does he become suficiently iluminated
to be visible...

all of this is really weird...

any help?

[Hugo Ferreira][Positronic Dreams][]
"Research is what I''m doing when I don''t know what I''m doing."
- Wernher Von Braun (1912-1977)

Share this post


Link to post
Share on other sites
Could it have to do with the cube being assigned a mainly specular material? Try giving the cube a diffuse material where you zero out the specular component and see what happens.

Henry

Share this post


Link to post
Share on other sites
I used to have the same problem. I would walk through a map and looking up or down changed the lighting. I think it has something to do with how light positions are transformed by OpenGL. If I remember correctly, everytime you change the projection or modelview matrix, you have to call glLight for your lights again, or something similar to that. You might want to check Red and Blue books on lighting.

Hope that helps

Share this post


Link to post
Share on other sites