Advertisement

OpenGL lighting problem

Started by August 01, 2000 04:37 PM
3 comments, last by AnCcE 24 years, 4 months ago
Strange OpenGL bug... never seen this one before. Okay, I have a light source, and I use glLightfv to specify everything and glEnable to finally enable the light. I KNOW the light is enabled, I''ve tested it with glIsEnabled, and I KNOW the position/color/attenuation info is getting set as well. Here''s the weird part: if I set attenuation values to anything besides constant=1, linear=0, quadratic=0, the light goes dead. glGetLightfv reveals that the attenuation values are indeed getting set, except.... no light. Doesn''t matter how close I set the light source to my model, I get nothing. Any ideas? Oh and I know it''s not a spotlight issue, spotcut is still 180. Thanks in advance Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Make sure that the light is placed "outside" the screen, or behind the camera. Also, use glEnable(GL_COLOR_MATERIAL) to make sure that your light interpolation is correct with the vertex colors you have.

Also, you''d have to have vertex normals if you''re smooth shading--glNormal3f().

Also, try have a key toggle lighting on or off to see if there is _any_ change in the scene. If there is change in the scene then the lighting _is_ working.

Hope that helps...
OldManDave.
Advertisement
this prolly aint the forum but try different values for the linear + quadratic
eg
glLightf(ID, GL_CONSTANT_ATTENUATION, 1.0);
glLightf(ID, GL_LINEAR_ATTENUATION, 0.01);
glLightf(ID, GL_QUADRATIC_ATTENUATION, 0.0005);

i know its difficult getting the right values pg 183 of the red book 1.1 explains the formula
<< dangit i deleted the quote... this will stand in for part of dave''s post >>

Hmm, why would that have any effect on anything? Also, since this is a simple demo I''m making right now, i''ve been using glMaterial to set matprops. When I check my values with GL functions, everything is getting set.

Zedzeek, I''ve been programming with 3d graphics since well before OpenGL became mainstream for coding games, and that''s the equation I''ve always used... I''ve worked out on pencil and paper the amount of light each vertex should get with my attenuation settings, and each one is getting a fair amount of light... it should be visible. I''ve read through the red book so many times it could make my head spin... I''m gonna try some more stuff tonight and see if it works... Wish me luck, i''m gonna need it.

Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
Hi there, I''m AnCcE, and you''d be too if you weren''t somebody else.
I had a problem once when I''m drawing colored triangles, with lighting, as the glMaterial didn''t do it''s job. Try glEnable(GL_COLOR_MATERIAL) instead of that you''re doing. See if it helps. Also, a better description of your problem will help a lot.

OldManDave.

This topic is closed to new replies.

Advertisement