CMSC 427 Computer Graphics Programming Assignment 5: Ray

CMSC 427 Computer Graphics
Programming Assignment 5: Ray Cast Rendering
Written Questions Due Date: Wednesday, December 10, 2014 end of class
Project Due Date: Sunday, Dec. 14, 2014 @ 9PM
NOTE: No late days are allowed for this project. You must turn in what you have.
Starter Code:
You can download the starter code from this Dropbox link:
https://www.dropbox.com/s/5j1p0fbrg19ibzl/starter_programming5_dec2.zip?dl=0
Project Submission:
Please email a zip file to the TA at jgbrad1(at)cs.umd.edu before the due date. Read
below for further instructions on what must be included.
Project Description
This project is designed to give you experience working with a key data structure that underlies the
majority of tracers: a bounding volume hierarchy (BVH). I’ve provided you with the code for building a
BVH where the split point is chosen as the midpoint of the dimension being split at a level of recursion.
You need to use the resulting data structure to accelerate ray-triangle intersections. You will also
modify building of the BVH to use the surface area heuristic and show that it produces a “better” BVH
that uses fewer ray-AABB and ray-triangle intersection tests to render your geometry. Last, to “stress
test” your implementation, you will modify the ray-casting code to cast many random rays per pixel and
average the result to help address aliasing.
NEW: Written Questions [Due Wednesday December 10, 2014]
I’m trying something new in this assignment. Below are questions that must be turned in on Monday to
get you thinking about the project. They count for 30% of this project’s grade. These can be hand
written and/or typed. Point distributions below will be used by the TA for grading.
1. Explain how the loop in GLview::Render() is similar to and different from how a scene is drawn
using OpenGL. Give several explanations. [10 pts]
2. In the Phong shading implementation in GLView::Render() the QVector3D e = eye whereas in
the fragment shader it is set to vec3(0,0,0). Why is this the case? [5 pts]
3. Mesh::storeBVH() builds a BVH. Explain in a series of detailed diagrams how this construction
works [30 pts]
4. Write in pseudo-code the traversal of a BVH. This must be recursive [20pts].
5. Write the pseudo-code for computing the surface area heuristic for a single given split position
(see details below). [10 pts]
6. Describe using text and diagrams a way of pre-computing the bounding boxes for each splitposition [20 pts].
Implementation Hints
BVH Traversal
This traversal should be recursive. You can gain additional performance improvements using the best
ray-triangle intersection to prune parts of the BVH you traverse. You also want to go down the nearest
first. Obviously, no traversal is necessary if the ray doesn’t hit the bounding box.
Surface Area Heuristic (SAH)
Use of the SAH will give you a different split position than the default mid-point. You need to score each
split position. This score is calculated as the following
A = (# of elements left of split) * (Surface Area of Bounding Box around these left-side elements)
B = (# of elements right of split) * (Surface Area of Bounding Box around these right-side elements)
Z = Total surface area of elements in current recursion
SAH Score = (A + B) / Z
You can pre-compute the bounding box areas for each of the splits so you do not have to re-build the
bound box for each split you create.
Run several experiments with the SAH on and off and compare how it improves on the number of rayintersection tests. In an HTML document you include in the assignment explain how you conducted this
experiment.
Anti-Aliasing
For anti-aliasing we provided an array of random values. You only need to use 5-10 of them per pixel.
Extra Comments About the Project
If you decide to use any C++11 features, include the following line in your cmsc427.pro file or else it will
not compile on other platforms. If you don’t know whether or not you’re using C++11, you likely do not
need to worry about this.
CONFIG += c++11
Project Submission:
A zip file containing only the following should be sent in an email to the TA. The .zip file should be
named as follows: YourFirstName_YourLastName.zip You must also turn in a SAHTest.html file that
describes the experiments you conducted to show that the SAH produces better performance in terms
the number of ray-triangle and ray-AABB intersections.
GLview.cpp (you will modify this file)
GLview.hpp (you will modify this file)
Mesh.cpp (you will modify this file)
Mesh.hpp (you will modify this file)
cmsc427.cpp
cmsc427.hpp
cmsc427.pro
cmsc427.ui
perfrag.fsh
perfrag.vsh
resources.qrc
texture.fsh
texture.vsh
solid.fsh
solid.vsh
Although you may compile and run your program from within Qt Creator for development purposes, it
must be able to be compiled from the command line using qmake followed by make (or nmake on
windows).
Project Grading
Your program will be graded based on correctness of implementation. Your code must be well
commented. Note that it will also be judged subjectively based on the simplicity and clarity of
implementation. An implementation that is easy to understand, but has few minor bugs will be scored
higher than a messy implementation with the same number of minor bugs.
Points for this project are distributed as follows:
•
•
•
•
•
Written questions (30%) [Due on Wednesday, December 10, 2014]
Implementation of Bounding Volume Hierarchy Traversal (25%)
Implementation of the Surface Area Heuristic (25%)
Anti-Aliasing by Casting Random Rays (15%)
Clean implementation (5%)