hi, I’m trying to use a light source that follows the viewer around to simulate the viewer holding a torch or other light.
All I want to achieve is the effect of light being bright around the viewer and fading off to darkness fairly quickly. I’ve been playing with attenuation parameters, but whole scene always seems to be too light.
Any ideas what values I should use?
Have you tried adjusting your ambient light values?
Try these :
glLightf(GL_LIGHTn, GL_CONSTANT_ATTENUATION, 1.0f);
glLightf(GL_LIGHTn, GL_LINEAR_ATTENUATION, 0.0f);
glLightf(GL_LIGHTn, GL_QUADRATIC_ATTENUATION, 1.0f);
Hmmm… I’ve tried setting all ambient light to zero. I’ve also tried
each with values ranging from 0.0 to 1.0.
They do seem to affect the scene – with more higher values for attenuation, the scene gets darker, but the lighting does not seem to change with respect to distance from the light.
I’m using color tracking. Maybe that matters. And I haven’t set any parameters for the surfaces of objects…
the correct distanceattentuationequation for lighting would be att=e^-(dst^2/radius^2)
the attentuationequation you can set up is
att=1/(a + bdst + cdst^2)
now the best approximiation is att = 1 / ( 1 + 0.5 * dst / radius + 0.5 * dst^2 / radius^2 )
GL_CONSTANT_ATTENTUATION = 1
GL_LINEAR_ATTENTUATION = 1 / ( 2 * radius )
GL_QUADRATIC_ATTENTUATIION = 1 / ( 2 * radius * radius )
use this with the radius of the light source
( at distance = radius the light is half the brightness as at distance = 0 )
it looks best i think…