<p>When you perform regular Monte Carlo integration over a hemisphere using $N$ samples, each sample represents $\frac{2\pi}{N}$ steradians. So the Monte Carlo integration for Lambertian BRDF is:</p>

<p>$$\frac{2\pi}{N}\sum_{i=1}^N\frac{\rho}{\pi}L_i*Cos\theta_i$$</p>

<p>For path tracing, you only take one sample per path segment, so because $N$=1, the above sum becomes:</p>

<p>$$2\pi\frac{\rho}{\pi}L*Cos\theta = 2\rho L*Cos\theta$$</p>

CC BY-SA 3.0
2016-11-16T14:53:17.753Z
Nice one, thanks. Trying to connect this to what my book has for MC estimator for the light going to the viewer: $\left \langle L_r(x\rightarrow\Theta) \right \rangle = \frac{1}{N}\sum_{1}^N\frac{L(x\leftarrow\Psi_i)f_r(x,\Theta\leftrightarrow \Psi_i)\cos(\Psi_i,N_x)}{p(\Psi_i)}$. The division is by the pdf which for non-cosine-weighted hemisphere sampling is $p(\Psi_i) = \frac{1}{2\pi}$. Dividing by a fraction is multiplication by reciprocal, and constant coefficient $2\pi$ gets pulled out from the sum. Does that make sense?
PeteUK
CC BY-SA 3.0
2016-11-16T15:24:45.793Z
Although I've now confused myself again because that Wikipedia article says "in the naive case above, there is no particular sampling scheme, so the PDF turns out to be 1". But isn't the pdf $\frac{1}{2\pi}$?
PeteUK
CC BY-SA 3.0
2016-11-16T18:05:27.777Z
Yes, pdf is $\frac{1}{2\pi}$ for uniform sampling over the hemisphere.
JarkkoL
CC BY-SA 3.0
2016-11-16T01:56:08.467Z
2016-11-16T01:56:08.467Z
JarkkoL
<p><a href="https://en.wikipedia.org/wiki/Path_tracing#Algorithm" rel="noreferrer">Wikipedia's path tracing algorithm</a> has the following line for the diffuse BRDF:</p>

<pre><code>Color BRDF = 2 * m.reflectance * cos_theta;
</code></pre>

<p>I'm a little confused as I've been reading that Lambertian surface BRDF is $\frac{\rho}{\pi}$ where $\rho$ is the reflectivity (albedo?) of the surface. Where does the $2$ come from?</p>

CC BY-SA 3.0
2016-11-15T22:38:57.493Z
I can't give you a deeper answer unfortunately (someone else surely will!) but the 2 comes from integrating the BRDF over the hemisphere.
You didn't ask, but you may also be wondering where the $\pi$ went.  It's assumed that your color values already include the adjustment for $\pi$.  You can read more about that here: https://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/
Alan Wolfe
CC BY-SA 3.0
2016-11-15T22:43:12.273Z
Thanks but why is the BRDF being integrated over the hemisphere at this stage of the algorithm when we're dealing with a single incident direction?
PeteUK
<brdf><pathtracing><diffuse>
Derivation of Wikipedia's path tracing diffuse BRDF
PeteUK
# Derivation of Wikipedia's path tracing diffuse BRDF

(Asked by: username_0 on 2016-11-15)

[Wikipedia's path tracing algorithm](https://en.wikipedia.org/wiki/Path_tracing#Algorithm) has the following line for the diffuse BRDF:

```
Color BRDF = 2 * m.reflectance * cos_theta;

```

I'm a little confused as I've been reading that Lambertian surface BRDF is $\frac{\rho}{\pi}$ where $\rho$ is the reflectivity (albedo?) of the surface. Where does the $2$ come from?

**Tags:** brdf, pathtracing, diffuse

> **Comments:**
> **username_1**: I can't give you a deeper answer unfortunately (someone else surely will!) but the 2 comes from integrating the BRDF over the hemisphere. You didn't ask, but you may also be wondering where the $\pi$ went.  It's assumed that your color values already include the adjustment for $\pi$.  You can read more about that here: https://seblagarde.wordpress.com/2012/01/08/pi-or-not-to-pi-in-game-lighting-equation/  
> **username_0**: Thanks but why is the BRDF being integrated over the hemisphere at this stage of the algorithm when we're dealing with a single incident direction?  

---

## 1 answers

### Answer by username_2 on 2016-11-16. Score: 6 | Accepted answer

When you perform regular Monte Carlo integration over a hemisphere using $N$ samples, each sample represents $\frac{2\pi}{N}$ steradians. So the Monte Carlo integration for Lambertian BRDF is:

$$\frac{2\pi}{N}\sum\_{i=1}^N\frac{\rho}{\pi}L\_i\*Cos\theta\_i$$

For path tracing, you only take one sample per path segment, so because $N$=1, the above sum becomes:

$$2\pi\frac{\rho}{\pi}L\*Cos\theta = 2\rho L\*Cos\theta$$

> **Comments:**
> **username_0**: Nice one, thanks. Trying to connect this to what my book has for MC estimator for the light going to the viewer: $\left \langle L_r(x\rightarrow\Theta) \right \rangle = \frac{1}{N}\sum_{1}^N\frac{L(x\leftarrow\Psi_i)f_r(x,\Theta\leftrightarrow \Psi_i)\cos(\Psi_i,N_x)}{p(\Psi_i)}$. The division is by the pdf which for non-cosine-weighted hemisphere sampling is $p(\Psi_i) = \frac{1}{2\pi}$. Dividing by a fraction is multiplication by reciprocal, and constant coefficient $2\pi$ gets pulled out from the sum. Does that make sense?  
> **username_0**: Although I've now confused myself again because that Wikipedia article says "in the naive case above, there is no particular sampling scheme, so the PDF turns out to be 1". But isn't the pdf $\frac{1}{2\pi}$?  
> **username_2**: Yes, pdf is $\frac{1}{2\pi}$ for uniform sampling over the hemisphere.  

---

