<p>Following some documents on internet, I divide my ray tracing result by PDF. Then it seem the D and G terms disappeared. Only F term is still visible, it looks like Fresnel only.</p>
<p><code>color = D(wh) * G(wo, wi) * F / (4 * wi.z * wo.z);</code></p>
<p><code>pdf = D(wi) * G1(wo) * abs(dot(wo, wi)) / (abs(wo.z) * 4 * dot(wo, wh))</code></p>
<p><code>color / pdf</code> looks very similar to F term. That's strange, I don't know what's wrong.</p>
<p>IMO, the <code>pdf</code> also has <code>D</code> and <code>G</code> term. If I divide the result by PDF, it's likely to neutralized the effect of <code>D</code> and <code>G</code>. But that's obviously wrong.</p>
<p>So, how to use the PDF in correct way. Do I have the correct form of PDF?</p>

CC BY-SA 4.0
2021-06-10T13:06:54.513Z
That's the point of a map with this density - to cancel out terms which may result in variance. The D and G are implicitly in the mapping function (i.e. how you sample the hemisphere).
lightxbulb
CC BY-SA 4.0
2021-06-10T21:49:21.810Z
You divide by the PDF when you are doing importance sampling, which means distributing your rays proportional to that PDF. If you just put in the division by the PDF without changing the distribution of rays to match, that wouldn't be right.
Nathan Reed
CC BY-SA 4.0
2021-06-11T04:20:07.737Z
Thanks, it's cos weighted sample. Although there are several lights, I didn't sample light directly right now. @lightxbulb
iaomw
CC BY-SA 4.0
2021-06-11T09:02:37.280Z
Why do you have G and D in the pdf if it is sampling with a cosine weighted density? You should have $\frac{\cos\theta}{\pi}$ as a pdf instead, in which case only the cosine cancels out.
lightxbulb
CC BY-SA 4.0
2021-06-11T10:47:17.513Z
Thx, I am using the TrowbridgeReitzDistribution from PBRT. It's also giving a PDF fucntion. So I tried it out. If I understand you correct, we only need to divide the PDF related to sample method(or bias), don't need to divide by the PDF from BXDF. That totally make sense. But when and how should I use the PDF from BXDF like TrowbridgeReitzDistribution. This is a bit confusing. PBRT is a bit too complex for me to finding this idea. @lightxbulb
iaomw
CC BY-SA 4.0
2021-06-11T22:48:08.347Z
The pdf you divide by is always wrt the sampling map. You can potentially construct a sampling map that has a pdf made of some terms of a brdf, but you will have to use this sampling in order to divide by these bsdf terms. I don't remember pbrt's brdf sampling procedures, so I can't comment on the latter part.
lightxbulb
<raytracing><ggx><pbrt>
Raytracing, divide by PDF neutralized the effect of D and G terms, what is the problem?
iaomw
# Raytracing, divide by PDF neutralized the effect of D and G terms, what is the problem?

(Asked by: username_0 on 2021-06-10)

Following some documents on internet, I divide my ray tracing result by PDF. Then it seem the D and G terms disappeared. Only F term is still visible, it looks like Fresnel only.

`color = D(wh) * G(wo, wi) * F / (4 * wi.z * wo.z);`

`pdf = D(wi) * G1(wo) * abs(dot(wo, wi)) / (abs(wo.z) * 4 * dot(wo, wh))`

`color / pdf` looks very similar to F term. That's strange, I don't know what's wrong.

IMO, the `pdf` also has `D` and `G` term. If I divide the result by PDF, it's likely to neutralized the effect of `D` and `G`. But that's obviously wrong.

So, how to use the PDF in correct way. Do I have the correct form of PDF?

**Tags:** raytracing, ggx, pbrt

> **Comments:**
> **username_1**: That's the point of a map with this density - to cancel out terms which may result in variance. The D and G are implicitly in the mapping function (i.e. how you sample the hemisphere).  
> **username_2**: You divide by the PDF when you are doing importance sampling, which means distributing your rays proportional to that PDF. If you just put in the division by the PDF without changing the distribution of rays to match, that wouldn't be right.  
> **username_0**: Thanks, it's cos weighted sample. Although there are several lights, I didn't sample light directly right now. @username_1  
> **username_1**: Why do you have G and D in the pdf if it is sampling with a cosine weighted density? You should have $\frac{\cos\theta}{\pi}$ as a pdf instead, in which case only the cosine cancels out.  
> **username_0**: Thx, I am using the TrowbridgeReitzDistribution from PBRT. It's also giving a PDF fucntion. So I tried it out. If I understand you correct, we only need to divide the PDF related to sample method(or bias), don't need to divide by the PDF from BXDF. That totally make sense. But when and how should I use the PDF from BXDF like TrowbridgeReitzDistribution. This is a bit confusing. PBRT is a bit too complex for me to finding this idea. @username_1  
> **username_1**: The pdf you divide by is always wrt the sampling map. You can potentially construct a sampling map that has a pdf made of some terms of a brdf, but you will have to use this sampling in order to divide by these bsdf terms. I don't remember pbrt's brdf sampling procedures, so I can't comment on the latter part.  

---

## 0 answers

