Sign in to follow this  
hick18

BRDF / BTDF pdf

Recommended Posts

hick18    102
Instead of taking paths for both the reflection and the Transmission rays at each intersection, im choosing to take only one using the BRDF to bias which route to take. To do this I evaluate the Schlick approximation function which gives me the amount of reflection at this intersection between 0 and 1. I use this and some randomness to decide on which route to take. I then divide by the pdf, but the result is just a white. Taking out the pdf divide gives a noisy but image as predicted, but isnt the divide supposed to be there?

I believe my problem is a normalization of the PDF issue. Not sure though. The left image is taking all paths, and the right is using the below technique (but without the divide by the pdf)

[attachment=2914:1.jpg]

[code]
virtual Vec3 Sample_f( const Vec3& wo, Vec3* pWi, const Vec3& P, const Vec3& N, RayInfo& ri, bool& reflec )
{
float costheta = AbsDot( wo, N );
float fresnel = Schlick( 0.04f, costheta );
float random = RandomFloat_0_1();
float pdf = fresnel;

if( random <= fresnel )
{
reflec = true;
BRDF_Specular s(m_R);
return s.Sample_f( wo, pWi, N ) / pdf;
}
else
{
reflec = false;
BTDF_Specular s(m_R);
return s.Sample_f( wo, pWi, N, ri.n, IoR() ) / pdf;
}
}
[/code]

Share this post


Link to post
Share on other sites
Pragma    395
Don't divide by the pdf. Try averaging a few hundred runs of the code that made the image on the right, and you should get something that looks like the picture on the left.

Share this post


Link to post
Share on other sites
sirpalee    759
[quote name='Pragma' timestamp='1307583703' post='4821164']
Don't divide by the pdf. Try averaging a few hundred runs of the code that made the image on the right, and you should get something that looks like the picture on the left.
[/quote]

What? When using multiple importance sampling, you need to divide with the PDF, since you are not using a randomly scattered direction on the hemisphere, but a direction what suits the actual BRDF more.

To the author, double check your function implementations...

What happens if you only sample reflection?

Share this post


Link to post
Share on other sites
Pragma    395
But from the code it's clear he isn't doing MIS, but Russian roulette sampling. Notice that the pdf he is dividing by has nothing to do with the BRDF being sampled, it's equal to the percentage of light that is reflected by the objects (as opposed to refracted). So dividing by pdf makes no sense.

Share this post


Link to post
Share on other sites
hick18    102
So do I just leave it as is but without the divide?

I thought I had to dived by the pdf to "boost" up cases where there might be say only 5% reflection and 95% refraction, and the 5% route happended to be chosen, giving almost black in those cases. But now I realise I dont need to boost it becuase Im not actually multiplying the result by the fresnel factor, im just using the fresnel to bias a route of 100% refraction or 100% reflection.

Share this post


Link to post
Share on other sites
Pragma    395
[quote name='hick18' timestamp='1307878863' post='4822362']
So do I just leave it as is but without the divide?
[/quote]
Yes.

[quote name='hick18' timestamp='1307878863' post='4822362']
I thought I had to dived by the pdf to "boost" up cases where there might be say only 5% reflection and 95% refraction, and the 5% route happended to be chosen, giving almost black in those cases. But now I realise I dont need to boost it becuase Im not actually multiplying the result by the fresnel factor, im just using the fresnel to bias a route of 100% refraction or 100% reflection.
[/quote]

Exactly.

Share this post


Link to post
Share on other sites
sirpalee    759
[quote name='Pragma' timestamp='1307731626' post='4821808']
But from the code it's clear he isn't doing MIS, but Russian roulette sampling. Notice that the pdf he is dividing by has nothing to do with the BRDF being sampled, it's equal to the percentage of light that is reflected by the objects (as opposed to refracted). So dividing by pdf makes no sense.
[/quote]

True. Then he should try using MIS :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this