In this post, I’d like to let you know the power of importance sampling.
First of all, see the images rendered with importance sampling and without importance sampling when choosing random ray direction.

(Path tracer with importance sampling)

(Path tracer without importance sampling)
Both use same the number of samples per pixel, thus the rendering time are identical for both images.
But you can see much more visual noise in the non importance sampled image.
For the image with importance sample, I’ve drawn the samples according to the following probability function,
%3D%5Cfrac%7B%5Ccos%5Ctheta%20%5Csin%5Ctheta%7D%7B%5Cpi%7D.png)
(i.e. generate samples proportional to cosine attenuation)
to generate random ray direction.
This importance sampling technique is widely used in many G.I. renderer.
For non importance sampled image, I’ve used following naive probability function
%3D%5Cfrac%7B%5Csin%5Ctheta%7D%7B2%20%5Cpi%7D.png)
(i.e. uniformly sample point on the hemisphere)
to generate random ray direction, then multiply cosine attenuation to the contribution.
Why so different?
Let me briefly explain why so the result image is different with and without importance sampling.
Importance sampling for the light integral.
Mathematically, Things what I’ve did in the above importance sampled image is reduced to computing the following integral.
.png)
(w_i is sampled with the PDF function p(w) = cos(theta) sin(theta) / PI)
Imagine if L(w) was always 1(e.g. uniformly lit sky), then the result of the integral become
(1 + 1 + 1 + … + 1) * (PI/N) = PI,
for any random number and for any N(# of MC samples).
The light integral with ordinal sampling.
On the other hand, The case of non-importance sampled image is formulated as follows.
%20cos(%5Ctheta_i).png)
(w_i is sampled with the PDF function p(w) = sin(theta) / (2 PI) )
Again imagine if L(w) always returned 1, then the integral will give
(cos(u0) + cos(u1) + cos(u2) + … + cos(uN)) * (2 PI / N) =
(0.34 + 0.56 + 0.90 + … + 0.12) * (2 PI / N) ~= PI
which is nearly equal to PI when N goes large, but not exactly goes to PI as in the importance sampled case.
There’s variance(error) in this case.
Conclusion
As a conclusion, the reason why 2 images are so different is due to the variance of cos(theta).
The variance of cos(theta) turned into more visual noise in non-importance sampled image.