Lighting Tutorial

The Inverse Square Law

The Inverse Square Law for light attenuation states that light intensity changes in inverse proportion to the square of the change in distance.

If the distance between an object and a light is increased by 2 times, lets say from 5 feet to 10 feet, then the light intensity that the object will receive is 22 = 4 times darker. Conversely, if the distance changes to, say, 1/3 the previous distance from the light, then the light intensity that now shines on the object is 32 = 9 times brighter.

Decreasing the distance from the light have the same effect as increasing the light intensity and vice-versa.

The Inverse square law is difficult to figure with abstract descriptions so I did a little animation to accompany the following description :

In this anim, there is a light source which emits photons hitting a square panel. The tiles on the floor each have 50cm sides. So the panel is located 100cm from the light source. As it is at the start of the animation, it receives 36 photons (in the real world, it would obviously receive way much more than that and they would not be organized in such a regular way. But the theory still hold the same).

Once photons leave a light source, they travel in a straight line until they hit a surface. The illumination intensity on the surface is equal to the total number of photons (this is a simplification of course).

So at start, the panel receives 36 photons as the panel moves away from the light source, it receives less and less photons. At 200cm, it now receives only 9 photons. 200cm is 2 times the distance as 100cm and 22 = 4 so the number of photons at 200cm is 1/4 it was at 100cm. 36/4 = 9.

When the panel have reached the end of its movement, it is now at 300cm from the light source and now recveives only 4 photons. 300cm is 3 times 100cm, 32=9 and 36/9 = 4.

This is where the inverse square law comes from.

The inverse square law is a simplification. It really holds only for point light sources. For differently shaped light sources, when the light source is relatively small compared to the object and relatively far from the object the inverse square law is still a very valid approximation. If a lighting designer keeps that law in mind, it should constitute a good background knowledge.

When the light source is relatively large compared to the object and relatively near the object, then, the situation gets a little more complicated. For example, the illumination provided by a fluorescent tube at 2 feet distance from an object can no longer be viewed as a single point light source. It can, however, be viewed as a array of point light sources placed in a linear arrangement next to each other. Same thing for a flat square luminaire. Such a light source can be thought of as a square array of point light sources.

In fact, in CG, differently shaped light sources, such as square (like a lighting pannel) or linear (like a fluorescent tube) or even oddly shaped (like a neon sign) are treated exactly as a large bunch of point light sources positionned on the surface of the actual light sources. This is essentially what the Monte-Carlo integration does by sampling the light surface at a multitude of sample points. And thus the light source, watever its shape, is considered as a collection of multiple sub-light sources all behaving according to the inverse square law.

The Lambert cosine falloff law

The idea is simple. When a surface faces a light, it receives the maximum direct illumination from the light. As the surface turns away from the light, it gradually receives less and less direct illumination until when the surface is completely flaring with the light, then it receives no direct illumination at all.

The following animation will help understand the principle.

When the surface is facing the light, it receives a certain quantity of photons. But as the surface turns away from facing light, it receives less and less photons untill it receives no photons at all.

As seen fron the light source, the surface appears to reduce in size according to the cosine of the angle between the light direction and the surface normal. Hence the name cosine law. This law was first published in 1760 by Johann Heinrich Lambert.

The default Phong diffuse shader that is used in every 3D applications including A:M is based on the Lambert Cosine law.

However, the cosine law is true for the quantity of light that reaches a surface but it is not a complete shading model because it does not take into account the viewer position.

As a shader, the cosine law is plausible for surfaces that are perfectly smooth and non-specular at the same time. A set of surface properties which cannot be found in nature nor on man-made objects because perfectly smooth and non-specular is a contradiction. A perfectly smooth surface would necessarily be highly specular. Nevertheless, the Phong diffuse shader is pervasively used in computer graphics and still produces very nice renders.

A good alternative to the Phong shader for rough surfaces is the Oren-Nayar shader which is a more complete shader since it takes into account the light and viewer position relative to the surface. And it can model different levels of surface roughness.