The following 566 words could not be found in the dictionary of 615 words (including 615 LocalSpellingWords) and are highlighted below:

18th   about   above   according   add   against   ahead   all   All   allows   already   always   amount   an   analytically   and   angle   answers   Answers   approach   approaches   approximating   Area   area   assignment   Assignment   assignment4   Assignment4   Assignments   associated   assume   at   At   attach   aware   back   Background   bad   base   based   Be   be   Before   being   below   better   between   body   book   both   Both   bottom   bsdf   build   but   by   called   calls   camera   can   care   careful   carefully   Carlo   case   cases   centered   certain   chapters   checkerboard   checking   choice   choose   choosing   chosen   class   clear   close   comes   compose   computation   compute   computed   computes   computing   configuration   consist   consists   construct   contain   containing   contains   contribute   contrived   controls   correct   Correct   correction   cos   cosine   courses   created   cs348b   default   define   defines   demonstrates   Describe   Description   designed   desirable   difference   different   direct   Direct   direction   directions   directlighting   disable   disabled   Discuss   discussed   distribution   distributions   dll   does   domain   don   done   down   download   draw   drawn   draws   Due   due   each   edu   effect   effective   Either   either   element   emitters   engineering   enormous   ensure   entering   entire   environment   Environment   equation   errata   Errata   especially   Estimate   estimate   estimates   estimator   example   Exceptionally   exercise   exhibits   exist   Explain   explain   explanation   explore   Exploring   expressions   exr   factor   far   field   file   final   find   findings   Firstname   following   For   for   Friday   from   From   front   function   generated   get   given   going   grace   graded   Grading   graphics   greatly   happy   hemisphere   homework4   how   How   however   However   illustrate   image   images   implement   implementation   implemented   Importance   importance   important   imprecise   improve   in   In   incident   include   Include   included   incoming   Incorrect   individually   infinite   Infinite   infinitesample   inform   information   Inspection   Instead   integral   integrals   integrand   integrated   integrating   integration   integrator   Integrator   integrators   interesting   into   inversion   Investigating   involves   irr   irradiance   its   itself   just   Killeroo   killeroo   killeroos   know   last   Lastname   latlong   learned   least   left   lens   less   Light   light   lighting   lights   Lights   like   link   Linux   lit   little   ll   look   looking   luminance   make   Makefiles   manifests   many   map   maps   marked   means   method   might   minimized   mis   mitigate   modifications   modify   modulated   Monte   more   most   much   Multiple   multiple   multiplying   must   name   need   new   nf   ng   noise   noisy   normal   note   Note   Notice   now   nsamples   number   numerically   object   objects   occur   of   on   One   one   only   or   other   others   otherwise   over   overall   page   pages   parameter   part   parts   pass   pathological   pbrt   pdf   pdfs   per   perform   phi   php   pixel   places   Please   please   png   point   points   position   possible   Possible   posted   practice   precisely   preferable   problems   proceeding   process   produce   produced   project   prone   properties   proportional   protected   Provide   provided   quality   Question   questions   Questions   radiance   random   randomly   ranging   read   Read   Reading   real   realism   realistic   reasonable   reduce   reduction   reflected   reflection   regions   related   remains   Render   render   rendered   Rendering   rendering   renderings   require   requires   respect   result   results   richness   right   same   sample   Sample   samples   Sampling   sampling   scale   scaled   Scene   scene   scenes   schemes   second   see   seen   select   sensor   set   Set   settings   severe   shaded   shared   shorter   should   shown   side   significantly   similar   since   situation   skylight   small   smaller   so   software   solid   solution   Solution   solve   some   source   sources   Specifically   specified   specify   specular   specularity   sphere   spheres   spotlight   stanford   Step   step   strategy   string   students   studio   Submission   such   sum   summation   summations   sunset   support   sure   Surface   surface   surrounding   Take   take   taken   technique   tell   terms   textbook   texture   than   that   The   the   then   there   therefore   these   theta   this   This   those   three   Thus   time   to   To   too   total   transport   true   Try   two   type   types   typo   unbiased   understand   understanding   uniform   Uniform   up   use   Use   used   useful   users   Using   using   value   values   variables   variance   various   varying   ve   verify   via   view   view1   view2   virtual   visual   way   We   we   weighted   weighting   well   were   what   When   when   whether   which   Why   why   wikipage   will   with   work   works   world   worst   would   Write   writeup   Writeups   wrong   x1   x2   You   you   Your   your   zip  


Assignment 4: Investigating Importance Sampling

Due: Friday May 18th, 11:59PM

Please add a link to your final writeup on Assignment4Writeups.


Rendering requires the computation of many different types of integrals. For example, in the last assignment we numerically integrated over the back element of the realistic camera lens to compute the irradiance incident on each pixel of your virtual camera's sensor. In this assignment you will take a close look at how pbrt computes the radiance reflected from a surface in a certain direction by integrating the surface's reflection function (BRDF) against incoming light from all directions.

pbrt numerically estimates the value of this integral via Monte Carlo integration. As you are now well aware, the variance of a Monte Carlo estimator manifests itself as noise in a rendered image. Thus, when integrating a function, it is important to choose samples from the domain of integration such that variance in the integral estimate is minimized. Importance sampling is a variance reduction technique that draws samples using a distribution that is proportional to the value of the function over the domain. In this assignment you will explore various approaches for sampling irradiance on scene objects due to an infinite area light source (environment light) and explain why and when certain approaches are preferable to others.

We are happy to inform you that this assignment is designed to be significantly shorter than Assignments 2 or 3.

Step 1: Background Reading

Read chapters 13 (especially 13.5), 14 (especially 14.3.4) and 15 (especially 15.6) in the pbrt book. This assignment will require a solid understanding of importance sampling, so please read the these chapters carefully.

Notice that there is a typo in the MULTIPLE IMPORTANCE SAMPLING EQUATION on pbrt page 676. The pbrt code core/transport.cpp is correct, the equation in the book is wrong. Instead of multiplying both summations by the factor 1/(nf + ng) as given in the book, the first summation (sum over samples drawn from a pdf from f) should be scaled by 1/nf. The second summation should be scaled by 1/ng. A correction is posted on the pbrt Errata page.

Step 2: Importance Sampling an Infinite Area Light

In the scenes we've rendered in this class so far, objects were lit using a small number of spotlight or area light sources. In the real world, light incident on an object comes not just from light emitters, but from all directions. One way of approximating this effect in pbrt is to use an environment light (infinite area light in pbrt), which is used to define light entering the scene from all directions due the surrounding environment. Environment lighting can greatly contribute to the realism and richness of your renderings, however, since computing environment lighting involves integrating incoming radiance over the entire hemisphere above a surface normal, in the worst case, Monte Carlo estimates are prone to be noisy, and require many samples to produce images of reasonable quality. In the scene below, images of the killeroo scene are rendered with 4, 8, and 128 samples per pixel.

killeroo_view1_grace_mis_irr_4 killeroo_view1_grace_mis_irr_8 killeroo_view1_grace

Importance sampling the environment map can make an enormous difference in the quality of the rendered image. Both images below are rendered using the same number of samples. In the image below at left, samples are drawn from a cosine-weighted distribution centered about the normal of the surface being shaded (see lights/infinite.cpp). However, in the case of an infinite area light, we know the light's luminance ahead of time, and therefore we can use this information to perform better sampling. At right, samples are drawn using a distribution that is proportional to the luminance of the environment map (see lights/infinitesample.cpp).

killeroo_view1_grace_light_cos_16 killeroo_view1_grace_light_irr_16

Question 1

As an exercise, assume that you are given an environment map with luminance L(phitheta) = cos(theta) when theta < PI/2 and L(phitheta) = 0 otherwise. Write down a pdf that could be used to sample the environment with respect to luminance. Use the inversion method to find expressions for phi and theta in terms of uniform random variables x1 and x2 so that a direction on the sphere is chosen randomly according to your pdf.

Note in a contrived case such as this, integrating the pdf analytically is possible. However, in practice in pbrt, radiance from the direction (phitheta) is given by the value of a texture map at position (u,v). In this case, to implement the inversion method, CDF must be computed numerically. This is precisely what is done by lights/infinitesample.cpp. Take the time to understand how this implementation works.

Step 3: Multiple Importance Sampling

Please download containing a number of scenes.

When computing reflected surface radiance due to direct lighting, pbrt computes an estimate of the integral of incoming light over all directions modulated by the surface's BSDF. To improve the quality of this estimate, it is desirable to use importance sampling when choosing a direction in which to sample incident radiance. The integrand consists of two terms, one related to the surface BSDF and the second related to radiance from light sources, and pbrt samples incoming radiance by drawing samples according to pdfs associated with each of the terms. This technique is called multiple importance sampling (MIS). It is implemented in pbrt in the file core/transport.cpp in the method UniformSampleAllLights.

1. We would like to you add support for a 'sample' parameter to the 'directlighting' integrator that allows you to select between using the default multiple importance sampling implementation, or sampling only according to either the pdf provided by the light or BSDF. Possible values of this string parameter are "bsdf", "light", and "mis". This parameter controls whether the samples are drawn from BSDF, light source, or both distributions. Set the default value to be "mis". When you disable MIS, make sure that your estimate of direct lighting remains unbiased. (How might you verify this?). We don't care too much about the software engineering you do to get this to work. One approach is to add a protected field to the {SurfaceIntegrator}}} base class for the type of sampling. Have it default to MIS and set its value in the CreateSurfaceIntegrator method at the bottom of integrators/directlighting.cpp. You then need to pass this value as a parameter to UniformSampleAllLights and EstimateDirect.

2. The scene mis.pbrt defines the scene that is shown on page 677 of pbrt. Render mis.pbrt with each of the 3 sampling schemes. You should get images similar those on page 677 in the textbook. Be sure that you render all scenes with the same number samples taken from the area light sources. Please be careful here: the number of samples specified as the area light parameter in the .pbrt file will need to change to ensure that the same number of light->Sample_L calls occur when MIS is disabled. Inspection of EstimateDirect should tell you why this is the case.

Question 2

When sampling according to the BSDF, some regions of the checkerboard are rendered with little noise, and in other regions noise is severe. Describe which is which, and explain why this is the case.

Question 3

Provide a similar explanation for the results you see when sampling with respect to the light sources. In this scene, are the bad cases when sampling with respect to the BSDF the same as the bad cases when sampling with respect to the lights?

Question 4

The image produced using multiple importance sampling exhibits the least amount of noise. How does this approach solve the problems you discussed in Questions 2 and 3? Specifically, how does the weighting in multiple importance sampling mitigate pathological cases?

Step 4: Exploring Importance Sampling in the Killeroo Scene

Before proceeding with this step, you'll need to build lights/infinitesample.cpp into a shared object called infinitesample.dll. Linux users should just modify the project or Makefiles from assignment 3 to do this. A project file already exist in the visual studio solution, it just is not marked to be included in the build process. Either build the project individually or include it in the solution build by checking the project name in (Solution properties/configuration properties).

The scene killeroo_view1.pbrt contains three killeroos, ranging in specularity from most specular at left to least specular at right. In front of the killeroos are a set of spheres also of varying specularity. Render killeroo_view1.pbrt with grace_latlong.exr as the environment lighting texture map with the following settings:

  • Use a total of 16 lighting samples to compute a direct lighting estimate (note this means you specify a smaller number for nsamples in your scene file when using MIS).
  • Try each of the 3 sampling schemes
    • BSDF only distribution
    • Light only distribution (using infinitesample as the light)
    • Using multiple importance sampling (with infinitesample as the light).

Question 5

Discuss parts of the image that look better when using BSDF sampling than when drawing samples from a pdf based on environment map luminance.

Question 6

Notice that overall, the image is less noisy when sampling using only the luminance pdf than when using multiple importance sampling. Is this also the case when rendering using the skylight-sunset.exr environment map? Explain what is going on here based on your understanding of how samples in lights/infinitesample.cpp are generated, and the content of the scene and the environment maps.

Question 7

We have seen that using environment map luminance as a pdf for importance sampling can significantly reduce the variance in rendered images. Is this always true? Describe a situation that this sampling strategy may not be as effective as the cosine-weighted sampling implemented in lights/infinite.cpp. Try and construct a scene that demonstrates this (only draw samples using the light's pdf in this experiment, do not use MIS).

Question 8

killeroo-view2.pbrt places the camera on the other side of the killeroos. From this angle, variance in the part of the images containing the body of the killeroos is more similar using all three sampling schemes (especially when using the skylight-sunset environment map). Why does this new choice of view result in the killeroos looking more similar?

Step 5: Submission

  • We've created wiki pages (FirstnameLastname/Assignment4) for all students in the class. Access to these pages is set up so that only you can view your page. Please compose your writeup on this page and link to it from the Assignment4Writeups page. Your writeup should consist of at least the following:

  • Answers to all 8 questions
  • A zip file contain your modifications to the pbrt source. Please attach this file to your wikipage.
  • Include any images in your writeup that are useful to illustrate what you learned.

Step 6: Grading

This assignment will be graded on a 4 point scale:

  • 1-2 point(s): Incorrect/imprecise answers to questions
  • 3 points: Correct answers to all questions
  • 4 points: Exceptionally clear answers or other interesting findings with the assignment