View Full Version : Attenuation / torch simulation
04-12-2001, 06:52 AM
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?
04-12-2001, 07:13 AM
Have you tried adjusting your ambient light values?
04-12-2001, 10:37 PM
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);
04-13-2001, 08:10 AM
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...
04-13-2001, 10:14 AM
the correct distanceattentuationequation for lighting would be att=e^-(dst^2/radius^2)
the attentuationequation you can set up is
att=1/(a + b*dst + c*dst^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..
Powered by vBulletin® Version 4.2.3 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.