cosine lobe sampling PDF back

Board: Home Board index Raytracing General Development

(L) [2015/01/09] [ost by raider] [cosine lobe sampling PDF] Wayback!

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!
(L) [2015/01/09] [ost by ypoissant] [cosine lobe sampling PDF] Wayback!

Why not use a more plausible and modern BRDF such as GGX ?
[LINK http://www.cs.cornell.edu/~srm/publications/egsr07-btdf.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.
(L) [2015/01/10] [ost by raider] [cosine lobe sampling PDF] Wayback!

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
Code: [LINK # 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);
}
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?
(L) [2015/01/10] [ost by ingenious] [cosine lobe sampling PDF] Wayback!

>> 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?
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.
(L) [2015/01/13] [ost by ypoissant] [cosine lobe sampling PDF] Wayback!

>> 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?
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.

Microfacet BRDF usually don't normalize to one (that is the albedo or directional-hemispherical 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 re-normalizing 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 re-normalized, the importance sampling of the BRDF still has a nice normalized albedo everywhere.
(L) [2015/04/01] [ost by josh247] [cosine lobe sampling PDF] Wayback!

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.
(L) [2015/04/02] [ost by koiava] [cosine lobe sampling PDF] Wayback!

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  >> josh247 wrote:cos(theta) / Pi cos(theta) describes distribution of energy and 1/Pi is normalization factor.
(L) [2015/04/02] [ost by josh247] [cosine lobe sampling PDF] Wayback!

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?
(L) [2015/04/02] [ost by friedlinguini] [cosine lobe sampling PDF] Wayback!

>> 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?
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).
(L) [2015/04/06] [ost by ypoissant] [cosine lobe sampling PDF] Wayback!

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.

back