cosine lobe sampling PDF
cosine lobe sampling PDF
Hi all!
I'm trying to sample modified Phong BRDF with cosine lobe distribution. I have no issues with generation of directions on spherical digon around perfect specular direction, but I have doubts on PDF instead. What I see in the Arvo's thesis in section 4.6.4 tells me I need to use O(n) (where n is the specular exponent) recurrent procedure to calculate PDF for each sample... for high orders of the exponent that seams too costly event with proposed stop condition on tolerance.
From that I have 2 questions:
1) Does cosine lobe sampling is useful at all in practice because of that issue with PDF evaluation?
2) Are there any good alternative sampling methods for highly specular BRDFs (by good I mean effective generation of the sample from the distribution, as well as effective PDF evaluation)
Thank you in advance!
I'm trying to sample modified Phong BRDF with cosine lobe distribution. I have no issues with generation of directions on spherical digon around perfect specular direction, but I have doubts on PDF instead. What I see in the Arvo's thesis in section 4.6.4 tells me I need to use O(n) (where n is the specular exponent) recurrent procedure to calculate PDF for each sample... for high orders of the exponent that seams too costly event with proposed stop condition on tolerance.
From that I have 2 questions:
1) Does cosine lobe sampling is useful at all in practice because of that issue with PDF evaluation?
2) Are there any good alternative sampling methods for highly specular BRDFs (by good I mean effective generation of the sample from the distribution, as well as effective PDF evaluation)
Thank you in advance!
Re: cosine lobe sampling PDF
Why not use a more plausible and modern BRDF such as GGX ?
http://www.cs.cornell.edu/~srm/publicat ... 7btdf.pdf
You don't have to guess/hack about sampling directions and pdf with this BRDF.
Sorry, it's been so long when I used Phong for sampling that I would not know how to directly answer your question. But you might want to look at SmallVCM code. It does sample reflections using the Phong function.
http://www.cs.cornell.edu/~srm/publicat ... 7btdf.pdf
You don't have to guess/hack about sampling directions and pdf with this BRDF.
Sorry, it's been so long when I used Phong for sampling that I would not know how to directly answer your question. But you might want to look at SmallVCM code. It does sample reflections using the Phong function.
Re: cosine lobe sampling PDF
Thank's for the link, I plan to implement some microfacet BRDFs as well as a next step. I thought of Phong as about quite simple model to implement for test purposes. But surprisingly it is not so simple.
However, I don't understand what you mean by "You don't have to guess/hack about sampling directions and pdf with this BRDF"... You mean simple cosine weighted distribution is the best option for complex BxDFs?
I've checked SmallVCM code. They just use the fallowing code for evaluating PDF
That's correct only for distribution around normal, but this is wrong when you generate lobe around specular direction (which is the case in SmallVCM code too), and they just pass specular direction as the first argument instead of normal when calling that function. For directions below tangent plane, they just simply return zero. That PDF do not normalize to one except for normal incident direction. As a result they should get brighter reflection at gazing angles, as they divide by lower values of PFD when integrating. Or I miss something obvious?
However, I don't understand what you mean by "You don't have to guess/hack about sampling directions and pdf with this BRDF"... You mean simple cosine weighted distribution is the best option for complex BxDFs?
I've checked SmallVCM code. They just use the fallowing code for evaluating PDF
Code: Select all
float PowerCosHemispherePdfW( const Vec3f &aNormal, const Vec3f &aDirection, const float aPower)
{
const float cosTheta = std::max(0.f, Dot(aNormal, aDirection));
return (aPower + 1.f) * std::pow(cosTheta, aPower) * (INV_PI_F * 0.5f);
}
Re: cosine lobe sampling PDF
Indeed, since the sampled ray directions are subsequently rotated to be centered around the reflection vector, some of them go below the surface. The contribution of such directions is zero so they are simply discarded without evaluation. But the sampling distribution is still correct and properly normalized, and as long as those directions are accounted as samples in the Monte Carlo estimator, it's all good. The distribution is simply slightly inefficient, because a small fraction of the directions it generates point below the tangent plane. There's no bias introduced, you can use it.raider wrote:That's correct only for distribution around normal, but this is wrong when you generate lobe around specular direction (which is the case in SmallVCM code too), and they just pass specular direction as the first argument instead of normal when calling that function. For directions below tangent plane, they just simply return zero. That PDF do not normalize to one except for normal incident direction. As a result they should get brighter reflection at gazing angles, as they divide by lower values of PFD when integrating. Or I miss something obvious?
Click here. You'll thank me later.
Re: cosine lobe sampling PDF
I mean that both the distribution and its pdf are part of the model and are well defined. You don't have to do tricks like rotating the sampling lobe around the reflection direction. And the distribution is not a simple regular lobe around the reflection vector. It more naturally models the elongation of the samples as the reflection vector tends toward the grazing angle.raider wrote:Thank's for the link, I plan to implement some microfacet BRDFs as well as a next step. I thought of Phong as about quite simple model to implement for test purposes. But surprisingly it is not so simple.
However, I don't understand what you mean by "You don't have to guess/hack about sampling directions and pdf with this BRDF"... You mean simple cosine weighted distribution is the best option for complex BxDFs?
Microfacet BRDF usually don't normalize to one (that is the albedo or directionalhemispherical reflectance) for all incident directions and all roughnesses. I actually don't know of any BRDF that correctly normalizes to one for every incident and roughnesses cases. But this is in part because of the energy loss due to multiple bouncing on microfacets that those models don't take into account. It is relatively easy to write a renormalizing function that sort of restore this lost energy.
Concerning samples that goes below the macrosurface. you also get this with the microfacet BRDF. Sometimes, you cannot select any of the available microfacet normals that wouldn't do that and there are no ways to avoid that. But once the albedo is renormalized, the importance sampling of the BRDF still has a nice normalized albedo everywhere.
Re: cosine lobe sampling PDF
Hello everyone, I can say this is my first post and I am very pleased to find a forum dedicated to such things. As my question pertains to this topic I thought it best to continue this thread rather than start another, but do say if otherwise.
After reading Philip Dutre's book on global illumination and looking at SmallVCM, I have gathered that the PDF for sampling a cosine lobe is cos(theta) / Pi. What I don't understand is why it is divided by Pi? I know that just integrating cos(theta) over [0, Pi / 2] is equal to 1, which I would have thought made that the correct answer. I'm sure it's very simple and If you could enlighten me I would be very thankfull.
After reading Philip Dutre's book on global illumination and looking at SmallVCM, I have gathered that the PDF for sampling a cosine lobe is cos(theta) / Pi. What I don't understand is why it is divided by Pi? I know that just integrating cos(theta) over [0, Pi / 2] is equal to 1, which I would have thought made that the correct answer. I'm sure it's very simple and If you could enlighten me I would be very thankfull.
Re: cosine lobe sampling PDF
In Physically Based Rendering one of the most important factor is Energy Conservation. This means that in every scattering event reflected energy isn't greater than the energy what he received.
So, in this case every BRDF must be normalized in such way that if you integrate over hemisphere using this BRDF integration result must be less than 1.
here
So, in this case every BRDF must be normalized in such way that if you integrate over hemisphere using this BRDF integration result must be less than 1.
here
cos(theta) describes distribution of energy and 1/Pi is normalization factor.josh247 wrote:cos(theta) / Pi
Colibri Renderer
Re: cosine lobe sampling PDF
Thanks for response koiava although I'm referring to to Monte Carlo sampling distribution rather than the BRDF and maintaining energy conservation (although your statement about 1 / Pi being the normalization factor is still relevant). Currently I have for example a microfacet material that respects the laws of energy conservation and ect... Now I would like to implement a better sampling strategy than just stochastically sampling hemispherical directions. To do this I use importance sampling and an approximation distribution such as cos(theta). However this will give be bias within the Monte Carlo integration, so to correct this I must divide the radiance received by PDF of the cosine distribution. Do correct me if I am wrong in my understanding so far.
The issue I find is that my images appear to get brighter when I use importance sampling due to the PDF always being less than one (well less than Pi) and therefore increasing the radiance when used for division. Surely when sampling the PDF the value should occasionally equal more than one so that the radiance is reduced, producing the same results as when I don't importance sample the hemisphere?
The issue I find is that my images appear to get brighter when I use importance sampling due to the PDF always being less than one (well less than Pi) and therefore increasing the radiance when used for division. Surely when sampling the PDF the value should occasionally equal more than one so that the radiance is reduced, producing the same results as when I don't importance sample the hemisphere?

 Posts: 89
 Joined: Thu Apr 11, 2013 5:15 pm
Re: cosine lobe sampling PDF
Are you sure your results were correct *before* you introduced importance sampling? With uniform sampling of the hemisphere you still have a pdf; it just has a different shape (constant 1 / (2 pi) I would assume, since you're integrating over half a sphere, and a sphere has area 4 pi r^2).josh247 wrote:The issue I find is that my images appear to get brighter when I use importance sampling due to the PDF always being less than one (well less than Pi) and therefore increasing the radiance when used for division. Surely when sampling the PDF the value should occasionally equal more than one so that the radiance is reduced, producing the same results as when I don't importance sample the hemisphere?
Re: cosine lobe sampling PDF
Intuitively
When you look at the density of a uniform hemispherical distribution, it looks like a hemisphere. Thus its surface is 2pi.
If you look at the density of a cosine distribution, you will observe that it is, itself, a sphere of one unit diameter or 0,5 radius above the surface. Thus its surface is 4pi * 0.5^2 = pi.
When you look at the density of a uniform hemispherical distribution, it looks like a hemisphere. Thus its surface is 2pi.
If you look at the density of a cosine distribution, you will observe that it is, itself, a sphere of one unit diameter or 0,5 radius above the surface. Thus its surface is 4pi * 0.5^2 = pi.