# BRDF / BTDF pdf

This topic is 2589 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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]

 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; } } 

##### Share on other sites
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 on other sites

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.

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 on other sites
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 on other sites
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 on other sites

So do I just leave it as is but without the divide?

Yes.

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.

Exactly.

##### Share on other sites

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.

True. Then he should try using MIS

##### Share on other sites
How would I apply MIS in this situation?

1. 1
2. 2
Rutin
22
3. 3
4. 4
JoeJ
15
5. 5

• 14
• 30
• 13
• 11
• 11
• ### Forum Statistics

• Total Topics
631776
• Total Posts
3002300
×