What values should I use for attenuation?

Started by
3 comments, last by timw 18 years, 6 months ago
I'm setting up lights (positional) on my map, but with the current values, I can't see my lights.
      glLightf(GL_LIGHT0 + j + LIGHTS, GL_CONSTANT_ATTENUATION, 2.0f);
      glLightf(GL_LIGHT0 + j + LIGHTS, GL_LINEAR_ATTENUATION, 1.0f);
      glLightf(GL_LIGHT0 + j + LIGHTS, GL_QUADRATIC_ATTENUATION, 0.5f);
Hey babe.
Advertisement
if I remember correctly the lighting values are set to

lighting value*(1/(A*d^2 + B*d + C))

where A, B and C are the Quadratic, Linear, and Constant attenuation values respective.

the lighting value is calculated based on the phong model. and it's then scalled by this amount. remember these terms try to simulate distance fall off of light sources, obviously the power of light falling on a surface decreases as the light gets further away from the surface.

to be physically correct(for point lights)

A = 4*PI
B = C = 0;

for debugging just set it to
A = B = 0;
C = 1;

this way there is no attenuation whatsoever.

Tim
Alright, but I now have a problem that may not be related to attenuation.

Only one wall is being lit, and it's the wall where I placed my light.

Screen:
http://img481.imageshack.us/img481/2883/lighterror1jk.jpg
Hey babe.
so you set attenuation like I said for debuging mode? hmm, this is just a shot in the dark, but maybe your normals are the wrong direction. I suggest inverting them and see what happens. also opengl has two lighting modes. front and frontandback. try this calling this before you draw.

glLightModelf(GL_LIGHT_MODEL_TWO_SIDE, GL_TRUE);

this enables two side lighting. if you try this and it works, it means that your normals are inverted(facing the wrong way).

also, try this before your calls to glBegin()/end():

glEnable(GL_NORMALIZE)

it may be that you're transformation is some how corrupting the normls. they need to be normalized for lighting intensity to be correct. are you specifing normals?

Tim
one more question, are you using spotlights? if you're using spotlights only objects in the cone defining the light will be lit. the wall isn't lit like I'd expect it to be, when using a point light. hmmm come to think of it, it kinda looks like a specular highlight, does it move with your view dirction? make sure your material properties have their diffuse reflectivity values set to something non zero.

Tim

This topic is closed to new replies.

Advertisement