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:

ρ=Ωfr(x,ωi,ωo)(ωi.n)dωi

where,

fr = BRDF at point x for incoming radiance along ωi and outgoing radiance along ωo
(ωi.n) = Weakening factor for incoming direction ωi and normal n
Ω = 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.

ρ=flambertΩ(ωi.n)dωi flambert=ρΩ(ωi.n)dωi

Now, let’s look at how to compute the integral Ω(ωi.n)dωi. 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 dx and height dy. The area of this patch is dx.dy. Since there are 2 variables, we need to compute a double integral for the range of x and y respectively.

RectangleArea=6x=24y=1dxdy=6x=2dx4y=1dy=[x]6x=2[y]4y=1=(62)(41)=12

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 R below.

We similarly isolate a small pathch for integration. The length of the patch is a tiny segment along the radius dr. 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 dθ 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 rdθ. 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 dr.rdθ. Now, let’s find the area of the circle via integration.

CircleArea=Rr=02πθ=0rdθdr=Rr=0rdr2πθ=0dθ=[r22]Rr=0[θ]2πθ=0=(R22)(2π)=πR2

Hemisphere Integration

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

Ω(ωi.n)dωi

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 0 to 2π.
θ is known as the elevation angle and its range is from 0 to π2.

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

Since the direction vector ωi and normal n are assumed to be unit length, and the weakening factor is invariant to the azimuth angle, we can rewrite Ω(ωi.n)dωi as

Ωcosθdωi=π2θ=02πϕ=0cosθ.rdθ.rsinθdϕ=r2π2θ=0sinθcosθdθ2πϕ=0dϕ

Using trigonometric identity sin(2θ)=2sinθcosθ, and substituting r=1 for unit hemisphere, we can rewrite this as

π2θ=0sin2θ2dθ2πϕ=0dϕ

Substituting, Θ=2θ such that dΘdθ=2, we can again rewrite this as

πΘ=0sinΘ2dΘ22πϕ=0dϕ=14[cosΘ]πΘ=0[ϕ]2π0=14×2×2π

Thus,

Ωcosθdωi=π

and from equation (2), we have

flambert=albedoπ

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.