CS 6620: Advanced
Rendering (Spring 2009)
Instructor: Kavita
Bala
Homework 2:
Monte-Carlo Rendering I (Direct Illumination and Shading)
Due Friday, March 13 2009,
11:59 pm
Do this
assignment in groups of 2
Refer to the FAQ page for updates.
1. Ray tracing with shaders
Using the provided ray-tracing code,
implement the following: extend your ray tracer to include pixel anti-aliasing,
using Monte Carlo sampling.
- Add a method to your Camera class called setPixelRaysPerPoint(int numSamples). This
is the number of rays you will shoot through each pixel. Use a box filter
to compute the weighted average of the pixel samples.
- Add a method to your Camera class called setPixelRaySamplingMethod(String method)
- If method is "uniform" then
pick the rays uniformly over the pixel
- If method is "stratified" then subdivide the pixel into bins and shoot
one ray randomly within each bin. Have the same number of bins horizontally
and vertically and make the number of bins be as close as possible to the
number of pixel rays per point.
2. Shading models
For this part of the
assignment you can assume that the light sources you will have to deal with
are small spherical lights. With a small light, you can assume that
visibility and emission will remain constant over the solid angle subtended
by the light source. First add support for the following materials:
-
Emissive
Lambertian
-
Modified Blinn-Phong
-
Cook-Torrance
-
Isotropic Ward
For this question you should not compute the contribution from indirect
lighting (that is, light that bounces more than once before it reaches the eye)
in this assignment. Thus, you should not see reflections of objects other than
light sources in materials.
Sample model files has been provided and you will
receive a few more later. If you use our code,
your submitted code will be run like this:
java -cp
submission.jar;vecmath.jar cs6620.RayTracer model.xml
If you turn in your own framework you will need to give us detailed
instructions on how to run.
3.
Direct Illumination
Extend your ray tracer to perform area sampling on light sources:
Add a method to your Camera class called setDirectIlluminationOnly
(String state). If state is "on", direct illumination
only is evaluated. If state is "off", both direct and
indirect illumination (next homework) will be evaluated.
- Sampling light sources: You can no longer assume that the light sources will
be small spheres. The light sources can be of any size and will be either
spheres or triangles. The Global Illumination Compendium
contains a method for generating uniform random samples on a triangle.
- Add a method to your Camera class called setShadowRaysPerPoint(int
numShadowRays). This will be the total number of shadow rays cast
to all the light sources at each point at which you cast shadow rays. For
example, if you had 10 light sources and shadowRaysPerPoint was 30, you would shoot
on average 3 rays per light (assuming you uniformly sample the light
sources). If shadowRaysPerPoint was 1, one of the light sources would be picked at
random at each point and have a shadow ray cast at it. This approach makes
the cost of shadow rays constant regardless of the number of lights in the
scene. The default value for this parameter is 1. Add a method to your Camera class called setShadowRaySamplingMethod(String
method):
- If method is "uniform"
then each light in the scene should get the same number of shadow rays
on average.
- If method is "area",
the probability of a light having a shadow ray cast to it should be
proportional to its area. The total number of shadow rays shot per
point should still be the number specified by shadowRaysPerPoint.
- If method is "power",
the probability of a light having a shadow ray cast to it should be
proportional to its power. The total number of shadow rays shot per
point should still be the number specified by shadowRaysPerPoint.
Hints:
- Orientation of triangles: Triangles emit and reflect in only one
direction, defined by the normal returned in the ray-triangle intersection
code. Similarly, there is no emission or reflection from the interior of
spheres.
- Noise in images: The images you will generate for the test scenes
provided will have noise. It would take a lot more samples and
therefore a lot more time to produce relatively noise-free images. However,
some images will be noisier than others. You will be graded on whether you
have a roughly correct amount of noise given the method used to generate
that image. Therefore, please do not use better (or worse) sampling methods
than the ones specified in the assignment.
- Sampling of spherical lights: There are many ways to do it:
1) The simplest thing to do is to sample the sphere uniformly. The problem
is this is noisy (at least half of the sphere is always pointing
"away")
2) Or you could sample the hemisphere facing the point.
3) Or you could sample the disk facing the point.
You must do either 2 or 3 for this assignment.
Submission instructions:
Submit this assignment through CMS. You should submit one result image produced
by your ray tracer for each of the test scenes provided. The image should have
a name corresponding to the scene used to create it (e.g. scene1.png for
scene1.xml).
Page maintained by Kavita Bala