<p>The importance sampling methods for the two reflection models you mentioned are different - they pretty much reflect their definition.</p>
<p>Cook-Torrance model describes the surface as a collection of microscopic mirror-like facets. The width of the reflection lobe depends on how much the orientation of the facets varies relative to the surface normal. This is what the microfacet normal distribution function (NDF) represents. So importance sampling is based on generating a microfacet normal according to the NDF. Again, relative to the surface normal. So it has to be transformed to the world coordinate frame, that is what TransformToWorld does.</p>
<p>Phong model instead uses a cosine fallof around the specular reflection. So it can be importance-sampled by choosing a zenith angle proportional to the cosine fallof and a uniform azimuth, relative to the reflected direction. And then again must be transformed to the world coordinate frame.</p>

CC BY-SA 4.0
2023-06-08T19:50:22.060Z
2023-06-08T19:50:22.060Z
Aleš Koblížek
<p>I'm trying to importance sample the Cook Torrance BRDF for my path tracer but I'm not sure about the part where you have to change the sample from one coordinate frame to another.</p>
<p><a href="https://www.gamedev.net/blogs/entry/2261786-microfacet-importance-sampling-for-dummies/" rel="nofollow noreferrer">This</a> resource states that</p>
<blockquote>
<p>the strategy is to importance sample the distribution term to get a
microfacet normal, and then transform everything from all vectors
relative to the normal to relative to the origin.</p>
</blockquote>
<p><a href="https://agraphicsguynotes.com/posts/sample_microfacet_brdf/" rel="nofollow noreferrer">This</a> blog doesn't mention any coordinate frame change.</p>
<p><a href="https://computergraphics.stackexchange.com/a/4994/20045">This answer</a> uses one with the <code>TransformToWorld</code> function but doesn't explain why.</p>
<p>I'm left confused as to when we need to change the coordinates of the sampled direction and more importantly, why it has to be done.</p>
<p>This article from GPU Gems even writes about a &quot;specular coordinate frame&quot;:</p>
<blockquote>
<p>Here, <img src="https://chart.googleapis.com/chart?cht=tx&amp;chl=%5Cphi_s" alt="phis" /> and <img src="https://chart.googleapis.com/chart?cht=tx&amp;chl=%5Ctheta_s" alt="thetas" /> are the spherical coordinates of the sample direction in a coordinate frame where the specular direction is the z-axis</p>
</blockquote>
<p>What is this specular coordinate frame? Where does it come from? Is it different from the coordinate frame handled by the <code>TransformToWorld</code> function of <a href="https://computergraphics.stackexchange.com/a/4994/20045">this answer</a>? Is it specific to the Phong BRDF?</p>
<p>Why do we need such a coordinate change?</p>

<pathtracing><importance-sampling><microfacet>
Importance sampling microfacet BRDF and coordinate frame
Tom Clabault
# Importance sampling microfacet BRDF and coordinate frame

(Asked by: username_0 on 2023-06-06)

I'm trying to importance sample the Cook Torrance BRDF for my path tracer but I'm not sure about the part where you have to change the sample from one coordinate frame to another.

[This](https://www.gamedev.net/blogs/entry/2261786-microfacet-importance-sampling-for-dummies/) resource states that

> the strategy is to importance sample the distribution term to get a
> microfacet normal, and then transform everything from all vectors
> relative to the normal to relative to the origin.

[This](https://agraphicsguynotes.com/posts/sample_microfacet_brdf/) blog doesn't mention any coordinate frame change.

[This answer](https://computergraphics.stackexchange.com/a/4994/20045) uses one with the `TransformToWorld` function but doesn't explain why.

I'm left confused as to when we need to change the coordinates of the sampled direction and more importantly, why it has to be done.

This article from GPU Gems even writes about a "specular coordinate frame":

> Here, ![phis](https://chart.googleapis.com/chart?cht=tx&chl=%5Cphi_s) and ![thetas](https://chart.googleapis.com/chart?cht=tx&chl=%5Ctheta_s) are the spherical coordinates of the sample direction in a coordinate frame where the specular direction is the z-axis

What is this specular coordinate frame? Where does it come from? Is it different from the coordinate frame handled by the `TransformToWorld` function of [this answer](https://computergraphics.stackexchange.com/a/4994/20045)? Is it specific to the Phong BRDF?

Why do we need such a coordinate change?

**Tags:** pathtracing, importance-sampling, microfacet


---

## 1 answers

### Answer by username_1 on 2023-06-08. Score: 2 | Accepted answer

The importance sampling methods for the two reflection models you mentioned are different - they pretty much reflect their definition.

Cook-Torrance model describes the surface as a collection of microscopic mirror-like facets. The width of the reflection lobe depends on how much the orientation of the facets varies relative to the surface normal. This is what the microfacet normal distribution function (NDF) represents. So importance sampling is based on generating a microfacet normal according to the NDF. Again, relative to the surface normal. So it has to be transformed to the world coordinate frame, that is what TransformToWorld does.

Phong model instead uses a cosine fallof around the specular reflection. So it can be importance-sampled by choosing a zenith angle proportional to the cosine fallof and a uniform azimuth, relative to the reflected direction. And then again must be transformed to the world coordinate frame.


---

