PDA

View Full Version : Attenuation range



Flandry
12-13-2001, 11:38 PM
Hi, i'm tring to simulate light from a fire in a night seen (lit by a dim white directional light) by using a yellowish positional light. I set the QUADRATIC_ATTENUATION high to make the effect fall off rapidly, but i can't seem to see much difference. I AM using a positional light. So my questions are:
1) What are the valid ranges for attenuation factors?
2) Is there something else i might be missing?

Thanks

Bob
12-14-2001, 03:28 AM
1: I guess just about any number, as long as it's positive, is a valid attenuation factor.
2: Probably, but can't tell, since you only said you had a problem with the attenuation. Post somde code.

chowe6685
12-14-2001, 03:36 AM
OpenGL lighting is calculated per vertex. This means that if the objects being lit are made up of several large primitives, lighting won't look very good. Try breaking whatever the light is illuminating into more polygons, that may help

Flandry
12-14-2001, 08:04 AM
I can't believe i spelled "scene" s-e-e-n. Ugh. Musta been late. But i digress.

Here's the code:

traits.insert( Traitsf::value_type( GL_LINEAR_ATTENUATION, 50.f ) );
traits.insert( Traitsf::value_type( GL_QUADRATIC_ATTENUATION, 51575.f) );

Well, that's where i set the properties of the LightParticle class. These are iterated and set at first binding, and it works for the other traits, so that's not the problem.

As you might notice, i've tried setting QUADRATIC to quite a large number, but as i said, i haven't seen much difference beyond 1.f or so, which is why i ask what the valid range of the value is. Obviously it can't be "about any positive number" since GLfloats are of a fixed bit length, but it may be that anything up to float max is ok.

So 1) is there a more elegant way to calculate glfloat max than using sizeof to find the bit depth and 2) would that be a valid value anyway?

Thanks once again for any comments.

Bob
12-14-2001, 12:59 PM
Here's the code:

traits.insert( Traitsf::value_type( GL_LINEAR_ATTENUATION, 50.f ) );
traits.insert( Traitsf::value_type( GL_QUADRATIC_ATTENUATION, 51575.f) );

Excuse me but... what does this code do? Does it actually set any parameters, does it place them in some sort of event queue, does it do anything at all? It doesn't say anything.

And by the way, a quadratic attenuation factor of about 51000 is probably a little bit too large. Are you aware that it's a factor and not a distance? A larger value of the constat will cause the light to fade to black faster.

Flandry
12-14-2001, 03:53 PM
As i stated, that's the code for setting the traits of the light in a class. These values are iterated and applied (via OpenGL calls) when the light is activated. I know the equation for attenuation as found in Red Book. What i'm trying to figure out is why even such a high quadratic value is doing very little to attenuate the light. I've tried many different values, and as i said before, i don't seem to see any difference above 1.f or so. It has me wondering what the valid range is and if there could be some other factor that makes it look like there's little attenuation even at a great distance. I have objects that are fairly highly tesselated, so i don't think the vertex granularity is the problem.

zed
12-14-2001, 06:04 PM
mate if u give me your email ill email a program i wrote which should explain it.

ps. im away working during the week thus post quickly

Flandry
12-19-2001, 12:13 PM
Well, i emailed it to you long ago, but maybe you meant here.

lovell@REMOVE_SPAMcs.utah.edu

Looking forward to getting to the bottom of this...


Originally posted by zed:
mate if u give me your email ill email a program i wrote which should explain it.

ps. im away working during the week thus post quickly