<p>Normal distribution functions are defined a bit differently than you might expect. They're not <em>strictly</em> a probability distribution over solid angle; they have to do with the density of microfacets with respect to macro-surface area. The upshot is that they're normalized with an extra cosine factor:
$$ \int_\Omega D(m) \cos(\theta_m)\, d\omega_m = 1 $$
This cosine factor accounts for the projected area of microfacets onto the macrosurface. When importance-sampling the NDF this cosine factor must be accounted for as well.</p>

<p>This is actually hinted at in the text of the paper, as it says</p>

<blockquote>
  <p>The equations for sampling $D(m) | m \cdot n |$ are:</p>
</blockquote>

<p>(just above equations 35–36). The $|m \cdot n|$ factor there is equal to $|cos(\theta_m)|$. So the quantity being sampled is not just the NDF itself, but includes this extra factor. Then, as you note, the sine shows up as part of the area element for spherical coordinates.</p>

<p>I wrote <a href="http://reedbeta.com/blog/hows-the-ndf-really-defined/" rel="noreferrer">a blog post</a> a few years ago that goes into more detail about this.</p>

CC BY-SA 3.0
2017-12-06T06:14:12.077Z
Ahh i see. that makes sense. thank you very much. EDIT: Awesome blog post as well!
Sebastián Mestre
CC BY-SA 3.0
2017-12-05T21:43:20.207Z
2017-12-05T21:50:09.517Z
2017-12-05T21:50:09.517Z
Nathan Reed
<p>The GGX NDF, as it appears on the paper where it is presented is:</p>

<p>$$D(m)=\frac{\alpha_g^2\space\chi^+(m\cdot n)}{\pi\cos^4(\theta_m)(\alpha_g^2+\tan^2(\theta_m))^2}$$</p>

<p>It is equivalent, in the range $[0,\frac{\pi}{2}]$, to the following formulation (notation simplified by me):</p>

<p>$$D(m)=\frac{\alpha^2}{\pi(\cos^2(\theta)(\alpha^2-1)+1)^2}$$</p>

<p>by finding the derivative of the inverse of the expresions used for importance sampling ($\theta_m=\arctan(\frac{\alpha\sqrt{\xi_1}}{\sqrt{1-\xi_1}})$ and $\phi_m=2\pi\xi_2$) presented in the same paper we can derive the following PDF:</p>

<p>$$p(m)=\frac{\alpha^2\cos(\theta)\sin(\theta)}{\pi(\cos^2(\theta)(\alpha^2-1)+1)^2}$$</p>

<p>When finding the corresponding PDF for, for instance, the Blinn NDF the only difference is a $\sin(\theta)$ in the numerator that comes from the fact that the NDF is a distribution over a hemisphere. So where does the $\cos(\theta)$ factor in the GGX PDF come from? </p>

<p>I think it is explained after formula (37) in the paper but i don't understand the reasoning behind it.</p>

<p>PD:here are the Blinn NDF and PDF as i understand them for reference</p>

<p>NDF: $\frac{n+1}{2\pi}\cos^n(\theta)$  --- PDF: $\frac{n+1}{2\pi}\cos^n(\theta)\sin(\theta)$</p>

<p>EDIT: here is a <a href="https://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.pdf" rel="nofollow noreferrer">link to the paper</a> in case it makes the question easier to answer</p>

CC BY-SA 3.0
2017-12-05T21:49:17.520Z
BTW, the Blinn–Phong NDF should have $n + 2$, not $n + 1$, in the numerator (see equation 30 in the paper).
Nathan Reed
CC BY-SA 3.0
2017-12-06T06:37:48.110Z
Yup, thank you. now I also understand that the exponent in the PDF should be n+1
Sebastián Mestre
<rendering><mathematics><brdf>
Where does the cosine factor comes from in the GGX PDF?
Sebastián Mestre
# Where does the cosine factor comes from in the GGX PDF?

(Asked by: username_0 on 2017-12-05)

The GGX NDF, as it appears on the paper where it is presented is:

$$D(m)=\frac{\alpha\_g^2\space\chi^+(m\cdot n)}{\pi\cos^4(\theta\_m)(\alpha\_g^2+\tan^2(\theta\_m))^2}$$

It is equivalent, in the range $[0,\frac{\pi}{2}]$, to the following formulation (notation simplified by me):

$$D(m)=\frac{\alpha^2}{\pi(\cos^2(\theta)(\alpha^2-1)+1)^2}$$

by finding the derivative of the inverse of the expresions used for importance sampling ($\theta\_m=\arctan(\frac{\alpha\sqrt{\xi\_1}}{\sqrt{1-\xi\_1}})$ and $\phi\_m=2\pi\xi\_2$) presented in the same paper we can derive the following PDF:

$$p(m)=\frac{\alpha^2\cos(\theta)\sin(\theta)}{\pi(\cos^2(\theta)(\alpha^2-1)+1)^2}$$

When finding the corresponding PDF for, for instance, the Blinn NDF the only difference is a $\sin(\theta)$ in the numerator that comes from the fact that the NDF is a distribution over a hemisphere. So where does the $\cos(\theta)$ factor in the GGX PDF come from?

I think it is explained after formula (37) in the paper but i don't understand the reasoning behind it.

PD:here are the Blinn NDF and PDF as i understand them for reference

NDF: $\frac{n+1}{2\pi}\cos^n(\theta)$ --- PDF: $\frac{n+1}{2\pi}\cos^n(\theta)\sin(\theta)$

EDIT: here is a [link to the paper](https://www.cs.cornell.edu/~srm/publications/EGSR07-btdf.pdf) in case it makes the question easier to answer

**Tags:** rendering, mathematics, brdf

> **Comments:**
> **username_1**: BTW, the Blinn–Phong NDF should have $n + 2$, not $n + 1$, in the numerator (see equation 30 in the paper).  
> **username_0**: Yup, thank you. now I also understand that the exponent in the PDF should be n+1  

---

## 1 answers

### Answer by username_1 on 2017-12-05. Score: 7 | Accepted answer

Normal distribution functions are defined a bit differently than you might expect. They're not *strictly* a probability distribution over solid angle; they have to do with the density of microfacets with respect to macro-surface area. The upshot is that they're normalized with an extra cosine factor:
$$ \int\_\Omega D(m) \cos(\theta\_m)\, d\omega\_m = 1 $$
This cosine factor accounts for the projected area of microfacets onto the macrosurface. When importance-sampling the NDF this cosine factor must be accounted for as well.

This is actually hinted at in the text of the paper, as it says

> The equations for sampling $D(m) | m \cdot n |$ are:

(just above equations 35–36). The $|m \cdot n|$ factor there is equal to $|cos(\theta\_m)|$. So the quantity being sampled is not just the NDF itself, but includes this extra factor. Then, as you note, the sine shows up as part of the area element for spherical coordinates.

I wrote [a blog post](http://reedbeta.com/blog/hows-the-ndf-really-defined/) a few years ago that goes into more detail about this.

> **Comments:**
> **username_0**: Ahh i see. that makes sense. thank you very much. EDIT: Awesome blog post as well!  

---

