mmp / pbrt-v4

Source code to pbrt, the ray tracer described in the forthcoming 4th edition of the "Physically Based Rendering: From Theory to Implementation" book.
https://pbrt.org
Apache License 2.0
2.75k stars 403 forks source link

How to calculate MIS weight more correctly in pbrt-v4? #326

Open Enigmatisms opened 1 year ago

Enigmatisms commented 1 year ago

According to the book pbr-book chapter 16.3 multiple important sampling, for given t and s, we can calculate the weight among different connecting strategies according to pdfFwd and pdfRev. Yet when I render the scene with specular BSDF components, MIS seems to yield suboptimal results, which is not consistent with my UDPT and the BDPT rendering of mitsuba0.6:

My renderer (unidirectional) pbrt-v4 (256 spp)
pbr-single-ball-pt-full output-mirror

We can see that, pbrt-v4 here has some shot-noise. I didn't think it was related to low spp, so I took sometime to figure out what happened (because the same issue happened in my BDPT renderer, which is implemented according to the theory of pbr-book, and therefore, same issue can be observed in pbrt-v3 as well), I found that it was caused by SDS path (s = 0, t > 4), see the figure below:

260c6cdee9eaf3d6432de5e23a8526c5

For the blue path (SDS caustics path?) here, since the vertices in the path are alternating between specular delta and non-specular type, the logic of the following code will never add any ri onto the sumRi, therefore the weight 1 / (sumRi + 1) will always be 1., which is usually larger than the weight of the red path (since we have multiple connecting strategies, therefore sumRi is always greater than 0.).

for (int i = t - 1; i > 0; --i) {
    ri *= remap0(cameraVertices[i].pdfRev) /
          remap0(cameraVertices[i].pdfFwd);
    if (!cameraVertices[i].delta && !cameraVertices[i - 1].delta)
        sumRi += ri;
}

I think this doesn't make any sense, about BDPT being worse than UDPT. MIS weight is the weight of a strategy w.r.t all the connecting strategies given s & t, so... could it be possible that we've only focused on the relative value but have ignored the absolute contribution of a path? The weight w.r.t all other strategies (in the example I present, there is NO other strategies) is 1 but maybe it doesn't mean that its absolute weight is that big. I know that using MLT might help but... what about the BDPT itself?


The scene file can be found here: mirror-ball.pbrt. Also, if we set the material of the ball to be glass with delta specular reflection and refraction, similar issue can be observed.

Enigmatisms commented 1 year ago

I might have found something: this problem might be related to the problem mentioned in 'A Markov Chain Monte Carlo Technique for rendering scenes with difficult specular transport' of Wenzel Jakob and Steve Marschner.

Does this mean that this problem is actually out of the scope of BDPT and we can not resolve this without more advanced technique even the same problem might not be observed in UDPT?