The main problem of Project 4 was that it was very slow. We needed to generate billions of rays in order to only a few go through the pinhole camera. One way to make the program run faster is by trying to generate more photons that go through the pinhole.  I did this by generating random points on the pinhole and then shooting photons toward those points.  In order to make the generated photons represent the physics of a uniformly-emitting light source, I generated 50% of photons using the old method (uniform throughout the scene), and 50% of photons using the new method (aimed at the pinhole).  Then, I adjusted the energy carried by each photon so that although the photons are no longer being sent uniformly into the scene, the energy carried by those photons is still distributed uniformly.
Project 6 - Importance Sampling
without motion blur
with motion blur
Results