POV-Ray : Newsgroups : povray.general : Light Attenuation Server Time
6 Dec 2021 13:15:31 EST (-0500)
  Light Attenuation (Message 1 to 10 of 10)  
From: Trevor G Quayle
Subject: Light Attenuation
Date: 9 Mar 2011 12:10:00
Message: <web.4d77b443f36cbfe281c811d20@news.povray.org>
For POV, light attenuation uses the function a=2/(1+(d/FD)^FP) [3.4.7.9] for
light sources.  However for materials, the light attenuation function is
similar: a=1/(1+(d/FD)^FP), but it also allows you to implement a realistic
exponential function: a=exp(-d/FD) by setting FP=>1000.  My general question, is
why has this more realistic function (generally following Lambert Law of
Absorption) not been implemented for light sources as well?  By playing with the
FD & FP values, a close approximation can be found for some range (the best
seems to be by using FP=exp(1)=2.72) however it is limited to a specific range
and not the whole distance (e.g an absolute deviation of ~+/-0.006 exists only
from a relative distance of about 1.74 on, for a pecentage deviation it is even
more limited, for a +/-10% deviation from ~1.51 to ~3.67)

-tgq


Post a reply to this message

From: Alain
Subject: Re: Light Attenuation
Date: 10 Mar 2011 13:02:34
Message: <4d79123a@news.povray.org>

> For POV, light attenuation uses the function a=2/(1+(d/FD)^FP) [3.4.7.9] for
> light sources.  However for materials, the light attenuation function is
> similar: a=1/(1+(d/FD)^FP), but it also allows you to implement a realistic
> exponential function: a=exp(-d/FD) by setting FP=>1000.  My general question, is
> why has this more realistic function (generally following Lambert Law of
> Absorption) not been implemented for light sources as well?  By playing with the
> FD&  FP values, a close approximation can be found for some range (the best
> seems to be by using FP=exp(1)=2.72) however it is limited to a specific range
> and not the whole distance (e.g an absolute deviation of ~+/-0.006 exists only
> from a relative distance of about 1.74 on, for a pecentage deviation it is even
> more limited, for a +/-10% deviation from ~1.51 to ~3.67)
>
> -tgq
>
>

For materials, the atenuation is the result of the interaction of the 
light with the material. Atenuation is caused by absorbtion.

For the light's atenuation over a distance, you need to use the inverse 
square rule to get realistic atenuation, and absolutely need to use 
fade_power 2. It's the spreading of the light's energy that causes the 
atenuation.
There is NO absorbtion in this case. As there is no absorbtion, any 
formula based on absorbtion would be totaly unrealistic.

The terms are the same, but the physical reality modeled is not.



Alain


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Light Attenuation
Date: 11 Mar 2011 16:55:01
Message: <web.4d7a9993315d1bec81c811d20@news.povray.org>
Alain <aze### [at] qwertyorg> wrote:

> > For POV, light attenuation uses the function a=2/(1+(d/FD)^FP) [3.4.7.9] for
> > light sources.  However for materials, the light attenuation function is
> > similar: a=1/(1+(d/FD)^FP), but it also allows you to implement a realistic
> > exponential function: a=exp(-d/FD) by setting FP=>1000.  My general question, is
> > why has this more realistic function (generally following Lambert Law of
> > Absorption) not been implemented for light sources as well?  By playing with the
> > FD&  FP values, a close approximation can be found for some range (the best
> > seems to be by using FP=exp(1)=2.72) however it is limited to a specific range
> > and not the whole distance (e.g an absolute deviation of ~+/-0.006 exists only
> > from a relative distance of about 1.74 on, for a pecentage deviation it is even
> > more limited, for a +/-10% deviation from ~1.51 to ~3.67)
> >
> > -tgq
> >
> >
>
> For materials, the atenuation is the result of the interaction of the
> light with the material. Atenuation is caused by absorbtion.
>
> For the light's atenuation over a distance, you need to use the inverse
> square rule to get realistic atenuation, and absolutely need to use
> fade_power 2. It's the spreading of the light's energy that causes the
> atenuation.
> There is NO absorbtion in this case. As there is no absorbtion, any
> formula based on absorbtion would be totaly unrealistic.
>
> The terms are the same, but the physical reality modeled is not.
>
>
>
> Alain

I understand the use of the inverse square for light fading.  I suppose I was
thinking of using the exp function for absorption, however genrally in air this
effect would be minimal.

However, I am not fully convinced the light fading model being used is correct.
For inverse square, I would think the genral function would be:

a= FD/(x^2)

There is a difference between this function and the one used: at x=1, the
functions are equal, however as x increases, the function used overcalculates
the value (eg, x=1.3 +25%, x=2.0 +60%, x=inf +100%).  Below x=1, the function
undercalculates the value (eg, x=0.7 -34%, x=0.5 -60%).

However the inverse square function does have its problems.  As it is an invers
function, it increases greatly as x decreases toward 0, to infinity at x=0.
This does make sense to some degree as we are basically calculating the flux
(lumens/area) and at x=0, the area is 0 (L/0 = inf).

I have posted a graphic in p.b.i to illustrate the differences.  Perhaps
generally the differences in a scene may seem subtle, but there may be
circumstances (eg, my Matinee scene) where it can make a difference.  The light
fading of the projector 'looks' ok, as we don't have any reference, but in
reality, the decay should occur quicker.  One way to get closer I suppose, is to
use a higher fade power in the formula (oddly, using exp(1) for the power gives
a reasonable balance between x=1 and x=4 with a variance from +12% to -28%),
however it is still not technically correct (perhaps that just bothers me as a
perfectionist...)

-tgq


Post a reply to this message

From: clipka
Subject: Re: Light Attenuation
Date: 12 Mar 2011 02:42:09
Message: <4d7b23d1$1@news.povray.org>
Am 11.03.2011 22:52, schrieb Trevor G Quayle:

> However, I am not fully convinced the light fading model being used is correct.
> For inverse square, I would think the genral function would be:
>
> a= FD/(x^2)
>
> There is a difference between this function and the one used: at x=1, the
> functions are equal, however as x increases, the function used overcalculates
> the value (eg, x=1.3 +25%, x=2.0 +60%, x=inf +100%).  Below x=1, the function
> undercalculates the value (eg, x=0.7 -34%, x=0.5 -60%).

The formula is defined as it is to account for the fact that real light 
sources are not point light sources.

> I have posted a graphic in p.b.i to illustrate the differences.  Perhaps
> generally the differences in a scene may seem subtle, but there may be
> circumstances (eg, my Matinee scene) where it can make a difference.  The light
> fading of the projector 'looks' ok, as we don't have any reference, but in
> reality, the decay should occur quicker. One way to get closer I suppose, is to
> use a higher fade power in the formula (oddly, using exp(1) for the power gives
> a reasonable balance between x=1 and x=4 with a variance from +12% to -28%),
> however it is still not technically correct (perhaps that just bothers me as a
> perfectionist...)

The proper way to do it would be to reduce fade_distance to a very small 
value, and increase the light intensity to compensate.

Maybe things become a bit clearer by writing the attenuation function 
differently:

   a =     2 / ( 1             + (d/FD)^FP )
     =     2 / ( FD^FP / FD^FP + d^FP  / FD^FP )
     =     2 / (       ( FD^FP + d^FP) / FD^FP )
     = FD^FP /         ( FD^FP + d^FP )
     =     c /             ( c + d^FP )

   a ~ 1 / ( c + d^FP )

If you'd choose c=0 and FD=2, you'd theoretically get the attenuation 
law you're asking for - except that you'd need an infinitely bright 
light source to compensate for the proportionality factor. So choose a 
very, very small FD (giving a very, very small c in the above formula), 
multiply the light source intensity by FD^FP (presuming you previously 
used FD=1), and you'll be fine. Even theater projectors aren't perfect 
in simulating a point light source, so it's also realistic.


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Light Attenuation
Date: 12 Mar 2011 09:40:01
Message: <web.4d7b850f315d1becb05ef170@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> The proper way to do it would be to reduce fade_distance to a very small
> value, and increase the light intensity to compensate.
>
> Maybe things become a bit clearer by writing the attenuation function
> differently:
>
>    a =     2 / ( 1             + (d/FD)^FP )
>      =     2 / ( FD^FP / FD^FP + d^FP  / FD^FP )
>      =     2 / (       ( FD^FP + d^FP) / FD^FP )
>      = FD^FP /         ( FD^FP + d^FP )
>      =     c /             ( c + d^FP )
>
>    a ~ 1 / ( c + d^FP )
>
> If you'd choose c=0 and FD=2, you'd theoretically get the attenuation
> law you're asking for - except that you'd need an infinitely bright
> light source to compensate for the proportionality factor. So choose a
> very, very small FD (giving a very, very small c in the above formula),
> multiply the light source intensity by FD^FP (presuming you previously
> used FD=1), and you'll be fine. Even theater projectors aren't perfect
> in simulating a point light source, so it's also realistic.

While your math is sound, a=c/(c+d^FP) is only equal to 1/(c+d^FP) for c=1 and
1/(c+d^FP) is only inverse square for c=0, so the equations can't be taken as
equivalent, and they aren't as I have already demonstrated.  A simple test of
this is that if a=1 at x=1, then it should follow that a=1/4 at x=2, but it
isn't, a=0.4 which is 60% higher than it should be.

I understand the with light sources in POV being points and this turns the
intensity to infinite, however there would be ways to overcome it while
generally preserving the function:

1. minimize the function to 1 (for this, a=1 for any x<FD)
in this case you are simulating the light surface to be at x=FD (i.e. a sphere
with r=FD), and essentially anything below (inside) gets a constant value

or
2. offset the function by FD so that a=1 starts at x=0
this is similar to 1, you are treating the light surface as a sphere of r=FD,
but you are offsetting it to the point light location (shrinking it to a point,
while just offsetting the function.

In either case, the light value you put in is the magnitude of the light at
light surface (r=FD).

I have already shown the difference in the graphic posted at p.b.i if you had a
look.  I am going to try to simulate it in my Matinee scene by using a constant
light (no fading) but apply the function to the media density, just to see how
different the effect is.

-tgq


Post a reply to this message

From: clipka
Subject: Re: Light Attenuation
Date: 12 Mar 2011 12:19:33
Message: <4d7bab25$1@news.povray.org>
Am 12.03.2011 15:37, schrieb Trevor G Quayle:

>> Maybe things become a bit clearer by writing the attenuation function
>> differently:
>>
>>     a =     2 / ( 1             + (d/FD)^FP )
>>       =     2 / ( FD^FP / FD^FP + d^FP  / FD^FP )
>>       =     2 / (       ( FD^FP + d^FP) / FD^FP )
>>       = FD^FP /         ( FD^FP + d^FP )
>>       =     c /             ( c + d^FP )
>>
>>     a ~ 1 / ( c + d^FP )
>>
>> If you'd choose c=0 and FD=2, you'd theoretically get the attenuation
>> law you're asking for - except that you'd need an infinitely bright
>> light source to compensate for the proportionality factor. So choose a
>> very, very small FD (giving a very, very small c in the above formula),
>> multiply the light source intensity by FD^FP (presuming you previously
>> used FD=1), and you'll be fine. Even theater projectors aren't perfect
>> in simulating a point light source, so it's also realistic.
>
> While your math is sound, a=c/(c+d^FP) is only equal to 1/(c+d^FP) for c=1 and
> 1/(c+d^FP) is only inverse square for c=0, so the equations can't be taken as
> equivalent, and they aren't as I have already demonstrated.  A simple test of
> this is that if a=1 at x=1, then it should follow that a=1/4 at x=2, but it
> isn't, a=0.4 which is 60% higher than it should be.

Note that the last line is "a ~ ...", not "a = ...". With the 
attenuation being a factor applied to the light brightness, it suffices 
to have a formula that is proportional to the desired one, and adjust 
the light brightness to compensate for the proportionality factor.

> I understand the with light sources in POV being points and this turns the
> intensity to infinite, however there would be ways to overcome it while
> generally preserving the function:
>
> 1. minimize the function to 1 (for this, a=1 for any x<FD)
> in this case you are simulating the light surface to be at x=FD (i.e. a sphere
> with r=FD), and essentially anything below (inside) gets a constant value
>
> or
> 2. offset the function by FD so that a=1 starts at x=0
> this is similar to 1, you are treating the light surface as a sphere of r=FD,
> but you are offsetting it to the point light location (shrinking it to a point,
> while just offsetting the function.

Both solutions are mathematically incorrect, both for point lights and 
for light sources of non-zero size. (Not to mention that they wouldn't 
be backward compatible with existing scenes.)

While the current formula requires some tweaking to the light brightness 
in case you change the FD, it is mathematically sound, and should be 
powerful enough to give you what you want, given proper settings.

(I'd also like to point out once again that realistic results can only 
be achieved with an assumed_gamma setting of 1.0. Did you check that 
this is what you're using?)


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Light Attenuation
Date: 12 Mar 2011 14:30:00
Message: <web.4d7bc88e315d1becb05ef170@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> >
> > While your math is sound, a=c/(c+d^FP) is only equal to 1/(c+d^FP) for c=1 and
> > 1/(c+d^FP) is only inverse square for c=0, so the equations can't be taken as
> > equivalent, and they aren't as I have already demonstrated.  A simple test of
> > this is that if a=1 at x=1, then it should follow that a=1/4 at x=2, but it
> > isn't, a=0.4 which is 60% higher than it should be.
>
> Note that the last line is "a ~ ...", not "a = ...". With the
> attenuation being a factor applied to the light brightness, it suffices
> to have a formula that is proportional to the desired one, and adjust
> the light brightness to compensate for the proportionality factor.

I know it was an approximation, but the point being that there is a difference
still, and it can be quite large if you know what you are looking at.  It is
difficult to get them to be equal or or close because they are different curves.
 Actually the closest I can get the two curves to match  is with power values of
2.5-3 not 2

>
> >
> > 1. minimize the function to 1 (for this, a=1 for any x<FD)
> > in this case you are simulating the light surface to be at x=FD (i.e. a sphere
> > with r=FD), and essentially anything below (inside) gets a constant value
> >
> > or
> > 2. offset the function by FD so that a=1 starts at x=0
> > this is similar to 1, you are treating the light surface as a sphere of r=FD,
> > but you are offsetting it to the point light location (shrinking it to a point,
> > while just offsetting the function.
>
> Both solutions are mathematically incorrect, both for point lights and
> for light sources of non-zero size.

I know they aren't correct, but the true 1/x^2 function is though, but it breaks
down at the low values because these aren't technically possible.  We have to
note what we are calculating, it isn't the total light brightness, it is the
birghtness per unit area and mathematically for a point, the area would be 0
giving infinity.  But in real-life we don't encounter this because we don't have
a point.  Light sources are going to have a finite, definable surface area.  So
in case 1 above, we are assuming that FD is the distance to the surface of the
light source from the theoretical point light.  In that case it doesn't really
matter what is inside the light source.  Of course using this would typically
necessitate using small values for FD.  If a large FD is used, then you have the
problem that you have a constant light with no attenuation for that distance
which is what the second option was to solve; it treats the point light as if it
were a finite light and starts the attenuation from there.

> (Not to mention that they wouldn't
> be backward compatible with existing scenes.)

If it was to be implemented, to be backward compatible it could be handled
similar to attenuation in interior where simply setting the fade_power>1000
kicks in the alternate function as this would not be a typical value used.

> While the current formula requires some tweaking to the light brightness
> in case you change the FD, it is mathematically sound, and should be
> powerful enough to give you what you want, given proper settings.

The current formula is not the true inverse square formula though, it just looks
similar from a distance and fixes up the point light/infinite brightness
problem.  What changes the function is the extra "1+...".

> (I'd also like to point out once again that realistic results can only
> be achieved with an assumed_gamma setting of 1.0. Did you check that
> this is what you're using?)

Yes, this is what I am using.

I know all of this doesn't really make a difference, as people are not going to
notice one way or the other or that it isn't quite the right falloff.  I just
got curious about it when trying to adjust my light fading.

-tgq


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Light Attenuation
Date: 12 Mar 2011 15:00:01
Message: <web.4d7bd0a4315d1becb05ef170@news.povray.org>
"Trevor G Quayle" <Tin### [at] hotmailcom> wrote:
> clipka <ano### [at] anonymousorg> wrote:

Don't get me wrong though, I do see your point.  Typically before I would use
large fade distances.  At least I have realized through this exercise that it is
optimal to set the fade distance very low and adjust the light intensity itself
to get the best correlation: the range that is incorrect becomes negligible in
size, as the x/FD term gets larger, the effect of the extra 1+ term diminishes.

-tgq


Post a reply to this message

From: clipka
Subject: Re: Light Attenuation
Date: 13 Mar 2011 05:34:35
Message: <4d7c8fab$1@news.povray.org>
Am 12.03.2011 20:25, schrieb Trevor G Quayle:

>> Note that the last line is "a ~ ...", not "a = ...". With the
>> attenuation being a factor applied to the light brightness, it suffices
>> to have a formula that is proportional to the desired one, and adjust
>> the light brightness to compensate for the proportionality factor.
>
> I know it was an approximation, but the point being that there is a difference
> still, and it can be quite large if you know what you are looking at.  It is
> difficult to get them to be equal or or close because they are different curves.
>   Actually the closest I can get the two curves to match  is with power values of
> 2.5-3 not 2

As I already mentioned, the key is not the fade_power, but the 
fade_distance. Sufficiently far away from the light source - relative to 
fade_distance (or, in other words, with sufficiently small fade_distance 
relative to the scene dimensions) - the formula gets arbitrarily close 
to 1/x^2.

>>
>>>
>>> 1. minimize the function to 1 (for this, a=1 for any x<FD)
>>> in this case you are simulating the light surface to be at x=FD (i.e. a sphere
>>> with r=FD), and essentially anything below (inside) gets a constant value
>>>
>>> or
>>> 2. offset the function by FD so that a=1 starts at x=0
>>> this is similar to 1, you are treating the light surface as a sphere of r=FD,
>>> but you are offsetting it to the point light location (shrinking it to a point,
>>> while just offsetting the function.
>>
>> Both solutions are mathematically incorrect, both for point lights and
>> for light sources of non-zero size.
>
> I know they aren't correct, but the true 1/x^2 function is though, but it breaks
> down at the low values because these aren't technically possible.  We have to
> note what we are calculating, it isn't the total light brightness, it is the
> birghtness per unit area and mathematically for a point, the area would be 0
> giving infinity.  But in real-life we don't encounter this because we don't have
> a point

Exactly - and that is why the current implementation is as it is.

> Light sources are going to have a finite, definable surface area.  So
> in case 1 above, we are assuming that FD is the distance to the surface of the
> light source from the theoretical point light.  In that case it doesn't really
> matter what is inside the light source.  Of course using this would typically
> necessitate using small values for FD.  If a large FD is used, then you have the
> problem that you have a constant light with no attenuation for that distance
> which is what the second option was to solve; it treats the point light as if it
> were a finite light and starts the attenuation from there.

The approaches you suggest, however, fail to account for the fact that 
at distances >0 from the light's surface you'll get not only 
illumination from the nearest point on the light's surface, but also 
from all other visible points of the light's surface. To my knowledge, 
the current implementation models this faithfully.

>> (Not to mention that they wouldn't
>> be backward compatible with existing scenes.)
>
> If it was to be implemented, to be backward compatible it could be handled
> similar to attenuation in interior where simply setting the fade_power>1000
> kicks in the alternate function as this would not be a typical value used.

No; that would make the whole thing inconsistent, because if a 
fade_power>1000 would be handled specially, users would likely expect it 
to give exactly the same formula as used with interior fading.

I'm currently toying around with the idea to implement special handling 
for fade_distance = 0 (which currently doesn't mean anything useful) to 
specify that a true 1/x^fade_power formula should be used (corresponding 
to an exact point light source), with the light brightness value 
specifying the intensity at x=1.0.

> The current formula is not the true inverse square formula though, it just looks
> similar from a distance and fixes up the point light/infinite brightness
> problem.  What changes the function is the extra "1+...".

As I previously tried to show, it /is/ sufficiently close to the inverse 
square formula when you specify a small fade_distance, and it is 
actually /more/ realistic than the inverse square formula.


Post a reply to this message

From: Trevor G Quayle
Subject: Re: Light Attenuation
Date: 13 Mar 2011 11:10:01
Message: <web.4d7cddd5315d1becb05ef170@news.povray.org>
clipka <ano### [at] anonymousorg> wrote:
> As I previously tried to show, it /is/ sufficiently close to the inverse
> square formula when you specify a small fade_distance, and it is
> actually /more/ realistic than the inverse square formula.

Yes, I have found this now.  What my problem was before was that I was using
very large fade_distance values.  If I use very small ones, it works out much
better.  This does mean usually that my light source intensities get huge: for
example, in my projector, the distance from my light to the screen is 2492, I
have a fade_distance of 4.58, my light intensity needs to be 148210 to have an
intenisty of 1 at the screen.  But it does look much better with the fall-off
rate I was more expecting.

-tgq


Post a reply to this message

Copyright 2003-2021 Persistence of Vision Raytracer Pty. Ltd.