首页 > > 详细

Project 2: Ray Tracing Instances and Acceleration

 Project 2: Ray Tracing Instances and Acceleration

Due Friday by 11:59pm Points 100 Submitting a file upload
Available Jan 30 at 9pm - Feb 20 at 11:59pm
Start Assignment
Objective
For this project, you will continue to add new capabilities to your ray tracer. First, you will add axis
aligned boxes as a new kind of primitive. Then you will create named objects and be able to make
multiple replicas (instances) of such objects in your scene. Instead of copying the primitives from a
named object, you are going to render an instance by transforming the ray by the inverse of the
transformation matrix for the object. Next, you will create a new kind of object that is simply a list of
other objects. Finally, your most difficult task will be for you to create a ray tracing acceleration data
structure. You can choose to implement either of these three options: 1) bounding volume hierarchies,
2) grids, or 3) k-D trees.
Project Description
You have several goals for this project:
1. Add axis aligned boxes as a new primitive
2. Be able to create a named object and make instances of such a named object
3. Create a list of objects and place them into an acceleration data structure for faster rendering
4. Create a scene that includes many copies of one of the large meshes (bunny, dragon, buddha, lucy).
You should re-factor your code so that the different varieties of objects you can render are all sub￾classes of one based Object class. Triangles and boxes should be subclasses of Object. An instance of
a named object should be a subclass of Object. Your ray acceleration data structure should be a
subclass of Object. By doing this, you should be able to have one list of objects that contain all of the
items to be rendered in your scene. Each object should be able to perform ray / object intersection,
returning information about the closest hit, if any. Each object should also be able to return an axis
aligned bounding box (AABB) that completely encloses the object. This will be very useful for
implementing your ray acceleration data structure.
In order for you to create named objects, you should maintain two separate lists of objects: the list of
objects that will appear in the scene, and a list of named objects. A named object will only appear in a
scene if one or more instances of it are made.
However you implement these new capabilities, your results should appear almost exactly like the
examples shown below in Results.
Begin with Your Project 1 Code
There is no provided code for this project. Since this project builds on top of Project 1A and 1B, you
should start with your project 1B code and add the new capabilities to it.
Provided Scene Files
There are several SCENE FILES (https://gatech.instructure.com/courses/295972/files/38827221?wrap=1)
(https://gatech.instructure.com/courses/295972/files/38827221/download?download_frd=1) that are
being provided for this project. You should modify your code so that pressing one of the keys 1-9, 0,
and "a" will load in the appropriate scene file. Notice that there are some .cli files (e.g. bun500.cli) that
are not full scene files, but that are used by some of the scenes (with the new read command). These
files will not create an image on their own, and so you do not need to be able to read these in directly.
Scene Description Language
As in Project 1, each scene is described by a text file with suffix ".cli". Each of these .cli files are just
plain text files, and you are encouraged to look at them. Sometimes you may find it useful to modify a
copy of these files to make debugging easier.
Below are the new commands that you will implement. Your ray tracer should also keep the functionality
of all of the commands from Project 1A and 1B.
box xmin ymin zmin xmax ymax zmax
Create an axis aligned box primitive, and put it on the list of objects in your scene. Do NOT create your
boxes out of triangles. You should intersect the ray with the six planes that describe the box, each of
which is perpendicular to one of the axes. Consult our textbook Physically Based Rendering for details
about this. You won't be rendering these boxes directly very often, but you will eventually make use of
AABB's in creating your acceleration data structure.
Just like triangles, boxes should be modified by the current transformation matrix when the box is
created. Do this by transforming the minimum and maximum corners of the box. This will cause the
expected results for translations and scaling. Don't worry that rotating an axis-aligned box will have
unexpected results.
named_object
Remove the most recently created object from the list of scene objects, convert this object to a named
object, and place it in your collection of named objects. A named object can be a triangle, an axis
aligned box, or an acceleration data structure that contains multiple objects.
instance
Create an instance of a named object and add that object to your list of scene objects. It is important
that you save the current transformation matrix C (or its inverse) as part of the instance. You will use C-1
to transform the ray when you ray trace this. This is how you can place multiple instances of the same
object in various places in your scene.
begin_accel
Begin creating a list of objects that is separate from the list of objects in the scene. This list will be
ended by the end_accel command.
end_accel
Finish putting objects into the separate acceleration list, and then place this list of objects into one of the
following acceleration data structures: 1) bounding volume hierarchy, 2) grid, or 3) k-D tree. It is your
choice which of these options you implement. Add this new acceleration object into the scene to be
rendered.
Create Your Own Scene
One of the requirements for this project is for you to create your own scene that draws many instances of
one of the large mesh files provided for this project. Your scene should include at least 20 copies of the
mesh you decide to instance. More is better! You can pick from among any of the four large meshes we
are providing: bunny (69k triangle version), buddha, dragon, lucy. We will be showing to the class some
of these scenes.
Include Code that Reports Rendering Time
When your program starts to render a given scene, it should start a timer by calling this routine:
int timer;  // global variable
void reset_timer()
{
  timer = millis();
}
When your scene is done rendering, you should then call this routine, which will print out how long it took
to render the scene:
void print_timer()
{
  int new_timer = millis();
  int diff = new_timer - timer;
  float seconds = diff / 1000.0;
  println ("timer = " + seconds);
}
You May Use Processing's Matrix Inverse Routine
When you implement object instancing, you will help to do this by storing the inverse of the current
transformation matrix, C . To calculate this inverse, you are allowed to use the PMatrix3D class' inverse
function that is built into Processing: PMatrix3D (https://processing.github.io/processing￾javadocs/core/processing/core/PMatrix3D.html)
Results
Below are the images that your program should generate for a given scene, when you press the keys 1-
9, 0, and "a". Notice that we ran out of digits, so jumped to the letter "a". The final scene should of
course be the one that you create that contains many instances of one of the large mesh objects.
-1
Authorship Rules
The code that you turn in entirely your own. You are allowed to talk to other members of the class and to
the instructor and the TA’s about general implementation of the assignment. It is also fine to seek the
help of others for general Processing/Java programming questions. You may not, however, use code that
anyone other than yourself has written. The only exception is that you should build on the code that you
wrote for Project 1. Code that is explicitly not allowed includes code taken from the Web, github, from
books, from the processing.org web site, from other students or from any source other than yourself. You
should not show your code to other students. Feel free to seek the help of the instructor and the TA's for
suggestions about organizing and debugging your code.
Submission
You will turn in your code via Canvas. In order to run Processing source code, it must be in a folder
named after the main pde file. For this reason, when submitting your project, you should keep your code
in this folder, zip up this folder, and submit this single zip file via Canvas. Make sure that your project
folder contains the "data" sub-folder and the .cli files it contains. Please do not use tar or rar to turn in
your files.
联系我们
  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp
热点标签

联系我们 - QQ: 99515681 微信:codinghelp
程序辅导网!