I've read in a thousand places "*the falloff for a spherical or point emitter is 1/d ^{^2}*" and I understand the geometrical reasons for the graph to have this shape.

If you have a sphere with radius=1m, then a section of it's surface with an area of 1m

^{2}subtends 1 steradian.

Increase the radius by 10x, and this surface area becomes 100x bigger.

So, if a point is emitting 100 photons per second per solid angle, then at 1m from the point, a detector covering our 1m

^{2}area will capture 100 photons per second, however at 10m away, it will only capture 1/100th as much, or 1 photon per second. Increasing distance by a factor of x caused a 1/x

^{2}reduction in photons captured.

...but there's a few details I'm sketchy on.

Most sources simply state that the inverse square law is true, without much further discussion. Many photography sources I've read go much further into layman's terms: "

*if you move the light twice as far away, the illumination will be one quarter*"...

To illustrate why I'm struggling with this fairly simple law, let's say we've got an American and an Australian doing the same test:

One measures the distance as being 2 feet, and calculates a falloff factor of 1/4.

The other measures the distance as being 0.6096m, and calculates a falloff factor of 2.69.

Obviously some detail is missing here Sure, if the American divides by 1-foot-in-metres

^{2}, he can convert his result over to match the scientific one... but to me, this indicates that the falloff factor isn't just a unit-less multiplier, it's measured in

*"energy" per "distance-unit" squared*, which is why they can convert their final results -- one is in

*energy*/ft

^{2}and the other in

*energy*/m

^{2}.

Is this right?

So does this mean that if you're working with lighting in units of lux, or lumens/m

^{2}, then this means that you should always use metres when calculating your distance-squared falloff factors? And likewise if you were working with foot-candles, you'd use feet in your distance-squared falloff calculations?

The other issue that I have is the pesky fact that 1/d^{2} goes to infinity as distance goes to zero.

This doesn't make any sense -- if I place a solar panel so that it's touching a light-bulb, I don't get limitless power for free!

Using this formula (4atan(ab/(2d*sqrt(4d^2 + a^2 + b^2)))), you can calculate the solid angle of a rectangle that is facing the centre of the sphere, with sides a&b and distance d from the centre of the sphere.

Say you've got a sphere with radius 1, and it's enclosed by a cube. One cube-face has a&b=2 and d=1. If you plug this in above, you get Pi*4/6 (*or 2.094sr*), which makes perfect sense, as the sphere has Pi*4 steradians total, and there are 6 equal cube faces surrounding it.

If again we say that the light is outputting 100 photons per second per solid angle, then this cube-face will capture 209.4 photons/s.

If we move this square so that it's 10 units away instead of 1, it's solid angle becomes 0.0396sr and it captures 3.96 photons/s (*not a 100x difference as before*).

If we move it so that it's 0.0000001 units away (*basically touching the light source*), then the solid angle doesn't go towards infinity, it reaches a limit at Pi*4/2 (*or 6.283sr*) and captures 628.3 photons/s -- i.e. it captures virtually everything emitted by one hemisphere, but can never do more than that!

Here is a plot of the inverse square law vs the solid-angle of a rectangle function. There's also a normalized (*0-1 range output*) version of both (*1/(1+x)^2 for inv-square-rule, and dividing by the maximum of 2pi for solid angle*).

What's up with the differences here?

With the inverse square law, the receiver/detector is a spherical cap, whereas with the solid-angle function the receiver/detector is a bounded plane. Wouldn't the latter be a better representation for most computer graphics uses?

Isn't the purple line on that graph really what we want to be using for distance attenuation?

However, having been perplexed by the fact that attenuation could go to infinity, I stumbled upon this blog post, which explains that the correct formula should actually be:

atten = 1/(d/r+1)^{2}

Where r is the radius of the emitter. This gives you the additional behaviour that you can tweak your light falloff values not just with arbitrary falloff multipliers or by tweaking the intensity -- you can use a larger emitter sphere to get more gradual falloff, which is something that seems to be missing from everything discussed above.

This formula is working pretty well for me, but it leads me to another problem: it only works for area lights (*which I guess everything is in the real world*); It hides the "naked singularity" of the basic version of the inv-square rule by ensuring that the distance is always greater or equal than the radius of the light.

...but I've read over and over that it's provable that a point light has 1/d^{2} falloff, and this formula doesn't work when the radius of the emitter is zero, so I'm still left puzzled about how to reconcile point emitters with spherical emitters. These two variants (*1/d ^{2} and 1/(d/r+1)^{2}*) give different answers, so... are they both right, but give answers in different units?

**Edited by Hodgman, 31 May 2013 - 09:49 AM.**