1
$\begingroup$

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 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 blog doesn't mention any coordinate frame change.

This answer 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 and thetas 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? Is it specific to the Phong BRDF?

Why do we need such a coordinate change?

$\endgroup$

1 Answer 1

2
$\begingroup$

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.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.