<p>In microfacet BRDFs, the half-vector is the same as the microfacet normal. The half-vector is exactly the required normal for a microfacet to reflect light from the incident ray to the outgoing ray, by the law of reflection. So, for given incident and outgoing directions, only those microfacets whose normals are aligned with the half-vector are "active".</p>

<p>Conversely, when importance-sampling a microfacet distribution, we wish to select a random microfacet normal, then reflect the incident ray through this normal to produce the outgoing ray. The incident and outgoing rays will then have the chosen microfacet normal as their half-vector.</p>

<p>For an isotropic BRDF, you will sample theta from the inverse CDF, and you must also sample phi, the azimuth angle about the normal, uniformly between 0 and 2π; then convert those into a unit vector using the usual spherical coordinates (as mentioned in the linked blog post), combined with a tangent-to-world transformation. For an anisotropic BRDF, both theta and phi would be supplied by sampling an inverse CDF.</p>

CC BY-SA 4.0
2019-01-10T17:49:06.763Z
But theta is the angle between the half-vector and normal right?  How can we use theta as a microfacet normal directly? Do we need to compute half-vector based on theta?
TIANLUN ZHU
CC BY-SA 4.0
2019-01-10T17:55:14.143Z
@TIANLUNZHU Yes, compute half-vector based on theta (and phi) using the spherical coordinates transformation.
Nathan Reed
CC BY-SA 4.0
2019-01-10T07:36:57.330Z
2019-01-10T07:36:57.330Z
Nathan Reed
<p>I've read many articles relating to importance sampling of GGX. However, I still feel confused.</p>

<p>The formula of GGX is :</p>

<p><a href="https://i.sstatic.net/jFUh6.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/jFUh6.png" alt="enter image description here"></a></p>

<p>And many article says we should use this formula to sample:</p>

<p><a href="https://i.sstatic.net/ecrsO.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/ecrsO.png" alt="enter image description here"></a></p>

<p>In the formula, theta is the angle between the normal and the halfvector. So what the formula shows is how to sample a angle between normal and halfvector? But, in the article <a href="https://schuttejoe.github.io/post/ggximportancesamplingpart1/" rel="nofollow noreferrer">https://schuttejoe.github.io/post/ggximportancesamplingpart1/</a>
it says "To importance sample D(ω^m) we will use the inverse of the CDF of D(ω^m) to generate a microfacet normal ω^m. If you are familar with using GGX in game rendering this can be thought of as creating a half vector in tangent space." How is theta related to microfacet normal? How can I sample a Li based on the theta?</p>

<pbr><importance-sampling><microfacet><ggx>
Can't understand the Importance sampling GGX
TIANLUN ZHU
# Can't understand the Importance sampling GGX

(Asked by: username_0 on 2019-01-10)

I've read many articles relating to importance sampling of GGX. However, I still feel confused.

The formula of GGX is :

[![enter image description here](https://i.sstatic.net/jFUh6.png)](https://i.sstatic.net/jFUh6.png)

And many article says we should use this formula to sample:

[![enter image description here](https://i.sstatic.net/ecrsO.png)](https://i.sstatic.net/ecrsO.png)

In the formula, theta is the angle between the normal and the halfvector. So what the formula shows is how to sample a angle between normal and halfvector? But, in the article <https://schuttejoe.github.io/post/ggximportancesamplingpart1/>
it says "To importance sample D(ω^m) we will use the inverse of the CDF of D(ω^m) to generate a microfacet normal ω^m. If you are familar with using GGX in game rendering this can be thought of as creating a half vector in tangent space." How is theta related to microfacet normal? How can I sample a Li based on the theta?

**Tags:** pbr, importance-sampling, microfacet, ggx


---

## 1 answers

### Answer by username_1 on 2019-01-10. Score: 3 | Accepted answer

In microfacet BRDFs, the half-vector is the same as the microfacet normal. The half-vector is exactly the required normal for a microfacet to reflect light from the incident ray to the outgoing ray, by the law of reflection. So, for given incident and outgoing directions, only those microfacets whose normals are aligned with the half-vector are "active".

Conversely, when importance-sampling a microfacet distribution, we wish to select a random microfacet normal, then reflect the incident ray through this normal to produce the outgoing ray. The incident and outgoing rays will then have the chosen microfacet normal as their half-vector.

For an isotropic BRDF, you will sample theta from the inverse CDF, and you must also sample phi, the azimuth angle about the normal, uniformly between 0 and 2π; then convert those into a unit vector using the usual spherical coordinates (as mentioned in the linked blog post), combined with a tangent-to-world transformation. For an anisotropic BRDF, both theta and phi would be supplied by sampling an inverse CDF.

> **Comments:**
> **username_0**: But theta is the angle between the half-vector and normal right?  How can we use theta as a microfacet normal directly? Do we need to compute half-vector based on theta?  
> **username_1**: @username_0 Yes, compute half-vector based on theta (and phi) using the spherical coordinates transformation.  

---

