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.8k stars 429 forks source link

MIS misbehaves: improvement for direct illumination #362

Closed rainbow-app closed 1 year ago

rainbow-app commented 1 year ago

Hello.

This is not a big problem or a bug. Images simply have (a little bit of) unnecessary noise. I tried both v3 and v4.

Problem description

Consider a narrow-angle spotlight, and its direct illumination on a matte surface. s+t=3, so maxdepth=1.

Reference image (crop around the spot): hall-orig1-crop

"Direct" lighting (also crop), the s=1,t=2 strategy: hall-opt1-crop

Notice the unnecessary noise in reference.

How to reproduce

The first image: I use the same scene (pbrt file) as I was using in my previous issue. Except that light intensity is 10 times smaller. Commands are same, except I don't do --level in convert. The second image: edit here and there the v3 bdpt.cpp appropriately. (I used my pbrt version to generate both images)

MIS's failing?

The noise in reference image comes from the "addsplat" image s=2,t=1. But how come MIS doesn't re-weight them properly?

It comes from different probability densities: forward from light to surface is large (since cone angle small), and reverse from camera to surface is small (fov is large). Much larger density from light makes this strategy s=2 have much larger weight (around 0.985). So MIS doesn't fail really, it works as it should, in accordance with Veach: more weight to the (contribution from the) more probable strategy.

But in the case of direct lighting we don't want this. So while I agree in general (s+t>3) with Veach and your implementation, we can enhance BDPT: opt out of using MIS for direct lighting.

Improvement

(needless to mention, when fixed, works better).

Disclaimer

My 5 cents. Point lights, matte surfaces. I don't know anything about volume scattering, area lights, multi-layer materials, and lots of other stuff.

mmp commented 1 year ago

I think this is a case of the general issue that MIS can slightly increase variance in "easy" cases where one sampling technique is very effective. (This can also be seen, for example, with regular direct lighting on a diffuse surface from an area light; sampling the BSDF and applying MIS often gives slightly higher variance than just sampling the light source.)

So, I think it's a good observation but I don't think there's anything to fix on the pbrt side of things.

rainbow-app commented 1 year ago

Right. I forgot that I've seen this discussion in Veach. Thanks.

I can't argue whether the additional complexity of the fix is worthy for your, general (unlike mine, special) system. Not worthy -- fine with me.