Deadlines

Checkpoint Quiz Tuesday 03/31, 11:59PM
Assignment 3-2 Friday 04/03, 11:59PM

With the current semester's modifications to the policy in light of recent events, you have a total of 8 slip days to use on assignments throughout the semester. You do not have slip days for checkpoint quizzes. Assignments submitted after 11:59PM are considered a full day late. There are no late minutes or late hours. After you have used all 8 slips days, you will lose 10% for each day you submit an assignment late.

Note the Friday due date, and the fact that the checkpoint date has been pushed back until after Spring Break. You may still wish to start the project before Spring Break, as rendering and the writeup can take some time.

Your final assignment submission must include both your code and write-up. Please consult this article on how to submit assignments for CS184.

Overview

In this project, you will add additional features to your ray tracer from Project 3-1, such as more complicated materials, environment lights, or depth of field effects.

NOTE: For this project, you will choose TWO out of the four given parts to complete. One of those parts must be Part 1 or Part 2. In other words, you can choose any combination of two parts except the pair (Part 3, Part 4).

This project will be shorter than 3-1, but rendering may still take some time. Please plan accordingly and leave time for renders/writeup. Start early!

Project Parts

Once again, you must choose TWO of the following parts, and one of those parts must be either Part 1 or Part 2. However, if you'd like to complete three, or all four parts, please do so! This project is one of the most rewarding to complete fully, as you'll be able to render almost anything at the end: all sorts of fancy materials in different environments, with any camera angle and focus depth.

Getting Started

Accept the assignment through the website, and clone from your private repo using the command:

git clone <YOUR_PRIVATE_REPO>

As before, refer to this how to build cs184 projects document to build your project.

Please consult the project 3-1 spec for details on the user interface. Here are some old and new command line flags you'll want to pay attention to:

  • -e some_map.exr loads an environment light .exr image file (part 3)
  • -b 1.23 sets the lens radius to 1.23 (part 4)
  • -d 4.56 sets the focal distance to 4.56 (part 4)

Please consider using the CGL Vectors Library to write all your math computations to simplify your code & ensure correctness. You can read the documentation of this library here

A new mouse interaction:

  • In render mode, after thin lens has been implemented, you can right click on a part of the image and automatically set the appropriate focal distance (autofocus). This is already done for people using pre-built binaries. For people using their own 3-1 code, you need to add this function to your pathtracer.cpp:
void PathTracer::autofocus(Vector2D loc) {
  Ray r = camera->generate_ray(loc.x / sampleBuffer.w, loc.y / sampleBuffer.h);
  Intersection isect;
  bvh->intersect(r, &isect);
  camera->focalDistance = isect.t;
}

As well as two new keyboard commands:

  • k | l: Increase/Decrease the camera lens radius
  • ; | ': Increase/Decrease the focal distance

Also please use the "cell render" mode to debug, where you can interactively click and drag to select a small region of the screen to be rendered. Press c (after pressing r) to toggle this mode in the GUI.

Integrating Previous Code

For Project 3-2, you will need a working implentation of Project 3-1. You have the option of either porting your code from Project 3-1, or using pre-compiled binaries generated from the staff solution.

Using Your Own 3-1 Code

To use your own code, set the build option BUILD_CUSTOM to ON in CMakeLists.txt. Then, you'll need to copy over the following files from your previous assignment, and place them in your src/ directory.

  • src/scene/sphere.cpp
  • src/scene/triangle.cpp
  • src/scene/light.cpp
  • src/scene/bvh.cpp
  • src/scene/bbox.cpp
  • src/pathtracer/camera.cpp
  • src/pathtracer/bsdf.cpp
  • src/pathtracer/pathtracer.cpp

Additionally, you will need to delete all the functions under part 3-2 code in your bsdf.cpp. This includes functions:

  • Spectrum MirrorBSDF::f(const Vector3D &wo, const Vector3D &wi)
  • Spectrum MirrorBSDF::sample_f(const Vector3D &wo, Vector3D *wi, float *pdf)
  • Spectrum GlossyBSDF::f(const Vector3D &wo, const Vector3D &wi)
  • Spectrum GlossyBSDF::sample_f(const Vector3D &wo, Vector3D *wi, float *pdf)
  • Spectrum RefractionBSDF::f(const Vector3D &wo, const Vector3D &wi)
  • Spectrum RefractionBSDF::sample_f(const Vector3D &wo, Vector3D *wi, float *pdf)
  • Spectrum GlassBSDF::f(const Vector3D &wo, const Vector3D &wi)
  • Spectrum GlassBSDF::sample_f(const Vector3D &wo, Vector3D *wi, float *pdf)
  • void BSDF::reflect(const Vector3D &wo, Vector3D *wi)
  • bool BSDF::refract(const Vector3D &wo, Vector3D *wi, float ior)

Using the Staff Library (Default settings)

The project has been configured to default to this settings. If you just cloned the repository, you can directly start building & writing code. You can also use this to check / compare your own project 3-1 solution.

To use the provided library, set the build option BUILD_CUSTOM to OFF (Default) in CMakeLists.txt. This will tell the generated makefiles to ignore your project 3-1 code, and include the library that matches your system instead. Note that the staff binary will generate a watermark on the corner of your image.

Writeup Guidelines

As in all previous projects, this project will require a writeup hosted on github classroom, and a pdf submitted to Gradescope. The goals of your write-up are for you to (a) think about and articulate what you've built and learned in your own words, (b) have a write-up of the project to take away from the class. Your write-up should include:

  • An overview of the project, your approach to the various parts, what problems you encountered and how you solved them. Strive for clarity and succinctness.
  • For each of the two (or more!) Parts you chose, make sure to include the specific results described at the end of each Part's spec. In addition to these generated images, make sure you include a short but clear summary of your implementation, as well as an explanation for why your images look the way they do, and the comparisons between them. If you failed to generate any results correctly, provide a brief explanation of why.
  • Clearly indicate any extra credit items you completed, and provide a good write-up and illustration.

The writeup is our main method of evaluating your work, so it is important to spend the time to do it correctly. Plan ahead to allocate time for the writeup well before the deadline.

Please do not just copy-paste words from the spec or lecture. Instead, try to connect the high level concepts expressed here with the actual programming you've done!

Here's another link to how to submit assignments for CS184.

Details

Do not convert or resize your .png. files. Use either the command line rendering mode or the S key to save screenshots, not your own OS's utility (like Project 1 and 3-1 but not like Project 2). Keep your images in a subdirectory called images/ in the docs/ directory. We recommend using the -r 480 360 command line flag to set resolution at 480 by 360 for your screenshots.

Please also make sure that your writeup indicates clearly which two (or more!) parts you chose.

Final Note

As mentioned earlier, each of the parts of this project gives you something to work with, and if you finish all of Project 3-2, you can basically render anything. When you're done, feel free to show it off! Make some fancy scenes and materials, or play with the lens! Again, be creative!