mrdoob/three.js — pull request #5787 by bhouston (2014-12-19 16:54:56+00:00)
Title: Physically-based Distance Attention for Spot and Point Lights (backwards compatible)

This adds Physically-Based light attenuation to Spot and Point lights in a backwards compatible way. For backwards compatibility decay exponent defaults to 0, no distance-based attenuation. Physically based light attenuation is decay exponent 2. But any decay exponent is supported.

This multiplies with the cutoffDistance linear attenuation if there is one.

This was was implemented using a function added to common.glsl (which is part of a separate PR):

```glsl
float calcLightAttenuation( float lightDistance, float cutoffDistance, float decayExponent ) {
float distanceAttenuation = 1.0 / pow( lightDistance, decayExponent );
if ( cutoffDistance > 0.0 ) {
distanceAttenuation *= 1.0 - min( lightDistance / cutoffDistance, 1.0 );
}
return distanceAttenuation;
}
```

PS. This is one of a series of PR's related to https://Clara.io's contribution of Physically Based Rendering to Three.JS.