Programming Assignment 2 - Monte Carlo Techniques ================================================= Due date: 8/06/2004. The goal of this exercise is to get some hands-on experience with Monte Carlo integration in the context of global illumination. More specifically, your assignment is to implement a Monte Carlo based "final gather" post-process, which follows the hierarchical radiosity global pass that you implemented in the first programming assignment. As you have noticed, the global illumination solution produced by the global pass stage of hierarchical radiosity is not suitable for direct display of high quality images. The radiosity function is approximated in a piecewise-constant manner and there are various artifacts around shadow boundaries. One way to generate a high quality shaded image after the global distribution of radiosity has been computed is by tracing rays from the camera via each pixel. After identifying the surface visible by each eye ray, an integration is performed in order to gather light from the rest of the environment to the visible point. This is not possible in ordinary ray tracing, since we have no information about the radiance on other surfaces in the scene, but it is possible to do after a radiosity pass, since we have an approximation of the radiance at each and every point in the scene. The problem is that you would like to use a limited budget of rays to shade each point, so the question is how to perform the integration efficiently. Here are three ways for you to implement and compare: 1. The naive way - sample uniformly the hemisphere about the normal at the point of interest. Minor improvements to this strategy would be to use stratification of the hemisphere, or alternatively generate the rays according to a cosine distribution, rather than a uniform one. 2. Simple importance sampling - a crude form of importance sampling will integrate the primary light sources, separately from the other surfaces in the scene. You need to decide which fraction of your ray budget will be spent in each of these two integrals, then compute each of them separately and add the results. 3. A more sophisticated importance sampling scheme will attempt to make smarter use of the information about the irradiance at each point of interest by looking at the links contributing to the element containing the point, and all of its ancestors in the hierarchy. From each of these links we can obtain a fairly good estimate of the relative importance of the source on the other end of the link to the receiving point. Design a sampling strategy that uses this information to get cleaner pictures faster than in the two previous methods. Bonus: 4. Diffuse scenes are just so boring... Make a floor, or some other surfaces in your scene(s) reflect the rest of the environment by recursively tracing reflected rays if they hit a reflective surface. This effectively turns your program into a hybrid radiosity/ray tracing renderer. It isn't physically correct, but makes nicer pictures.