I rewrote the whole project based on another base code (https://wjakob.github.io/nori/)because the old code written for the past assignments is badly-structured if I wanna build a good path tracer.
And here are two topics I referenced from, very useful:
So here are three ways talked at class about the way of doing path traicng.
Image1(200ssp) 2.1min brute-force path tracing(with russian-roulette). not slow but image quality is not good. Even if using 1000 ssp, the image is also not the one that we want.
Image2 500ssp 8.3min path tracing with nee. good quality, but obviously a little brighter.
Image3 800ssp 6.2min path tracing with MIS
I made a mistake when working on the MIS part. If you do MIS on the direct and indirect illumination at the same time, there is a problem. When rendering pixel on the areas that close to the ceiling, the lightpdf is fairly large for the pdf is computed with solid angle which is the same measure of brdf sampling. Then the indirect contribution lead by following paths will be close to zero because lightpdf is large. And those areas will gain little indirect illumination. So the correct way of dealing with this is that you only do MIS in the direct illuminaition part. That's to say, every time you calculate direct illumination you trace two rays, weighted by the balance heuristic.