# Deriving Lambertian BRDF from first principles

This is a short exercise on integration. We will derive the Lambertian BRDF from first principles to understand the origin of in it.

We start by stating that the Lambertian BRDF is , where (albedo) is the measure of diffuse reflection. It is the proportion of incident light that is reflected from a surface and is used to denote how *bright* a surface is (not to be confused with how *reflective* a surface is). Albedo maps are used ubiquitously in lighting, and look like this.

However, we need to come up with a more formal mathematical definition in this case. Real Time Rendering 4th Edition defines albedo as the **hemispherical-directional reflectance** which measures the *amount of light reflected along a given direction for incoming light in any direction in the hemisphere around the surface normal*. It can be represented as:

where,

= BRDF at point for incoming radiance along and outgoing radiance along

= Weakening factor for incoming direction and normal

= This is used to denote the integration over the unit hemisphere

*Note: If this looks familiar to the rendering equation, it is because it is. Albedo corresponds reflected radiance from a perfectly diffuse surface when lit uniformly by light of unit radiance.*

Since the Lambertian BRDF is a model of diffuse reflectance it is invariant to the the viewing direction. In other words, it is constant and can be taken out of the itegral.

Now, let’s look at how to compute the integral . But, first let’s do a quick refresher on integral calculus.

### Review

Informally, integration is the process by which we divide a region into *tiny parts* and then sum all those parts for the entire region to evaluate the property we are interested in such as area or volume.

So, let’s start with computing the area of a rectangle using integration. Here, we define a rectangle in Catesian coordinates. We identify a small patch with length and height . The area of this patch is . Since there are 2 variables, we need to compute a double integral for the range of and respectively.

This checks out since the area of the rectangle for length 4 and height 3 is 12.

Next up, let’s try to compute the area of a circle of radius below.

We similarly isolate a small pathch for integration. The length of the patch is a tiny segment along the radius . Computing the arc length of the patch is sligtly tricky. We need to somehow find a way to represent it in terms of the angle represented in radians. Fortunately for us, there is a direct relationship between radians and the length of the arc that subtends that angle. [link]

So, the length of the arc is . But what is the area of the patch? Turns out we can straighten the arc into a straight line, thereby converting our curved patch into a rectangle. This is known as rectification.

With that out of the way, the area of the patch can be simply represented by . Now, let’s find the area of the circle via integration.

### Hemisphere Integration

With that out of the way, let’s get back to solving equation . Here, we have to compute an itegral over the hemisphere.

Like earlier, we have to identify a small patch that we can integrate on. For that we resort to spherical coordinates.

Here,

is known as the *azimuth angle* and its range is from to .

is known as the *elevation angle* and its range is from to .

The following diagram shows us how such a patch can be constructed. The term is same as earlier since it lies on the great circle or meridian. The radius of other circle is smaller – . Hence, the length of that arc is as shown below.

Since the direction vector and normal are assumed to be unit length, and the weakening factor is invariant to the azimuth angle, we can rewrite as

Using trigonometric identity , and substituting for unit hemisphere, we can rewrite this as

Substituting, such that , we can again rewrite this as

Thus,

and from equation , we have

Hope you enjoyed this post. To understand its implications in lighting calculations check out this post by Sébastien Lagarde - Pi or not to Pi in game lighting equation.