Sampling Distribution Of Normals

The following algorithms and derivations are for the three commonly used distribution of normal functions for microfacet BRDFs: Beckmann, Phong and Trowbridge–Reitz/GGX.

Note, that all the sampling algorithms are for the microfacet normal, which is used to reflect the incoming ray to get the outgoing direction. Because of that, all probabilities have to be scaled by 14ωoωh=14ωiωh\frac{1}{4\omega_o \cdot \omega_h} = \frac{1}{4\omega_i \cdot \omega_h} to account for the change of measure between the sampled normal (half vector) and incoming direction.

I used the distribution formulas given in Walter et al. (Microfacet Models for Refraction through Rough Surfaces), though I did change the notation a bit to make it easier to write. Hopefully there won't be any confusion. The characteristic functions for the hemisphere check are not included, as they are not that relevant for the sampling, though you should be careful to include them in an implementation that needs to compute the probability densities for arbitrary directions.

Note, that these distributions of normals are normalized, such that:

ΩD(ω)cosθdω=1\int_\Omega \operatorname{D}(\omega)\cos\theta d\omega= 1

This means, the PDF is D(ω)cosθ\operatorname{D}(\omega)\cos\theta