Assignment 5 -- Ray Tracing
We strongly suggest you read all of this page before starting. The last section, which is a brief code walkthrough, may prove to be especially helpful.
How do I get started?
To get started, you should do the following:
- On Athena, type (if necessary)
- athena% attach 6.837
- Make a working directory, for example, by doing
- athena% mkdir ~/working
- Copy the assignment source there:
- athena% cp /mit/6.837/as5_ivray/ivray.tar ~/working
- Go to your working directory:
- athena% cd ~/working
- Unpack the assignment source, producing directory ivray:
- athena% tar xvf ivray.tar
- Go to the ivray directory and make the executable:
- athena% cd ivray; make
- Now you can run the (incomplete) executable:
- athena% ivray asst5test1.iv
- A "reference executable" can be found at /mit/6.837/as5_ivray/ivray.
What's going on here?
In this assignment, you will be filling in the guts of a real ray tracer.
We have given you all of the infrastructure. Once you obtain and compile the assignment code, you may run the ray tracer but important functionality will be missing. You will be editing
selected subroutines in order to supply this basic functionality.
How do I run the executable?
Ivray is a ray tracer that runs in a modified SceneViewer. You can try it
by running:
athena% ivray asst5test1.iv
Through the command line, you can specify an inventor file to load (by simply giving a .iv filename) and
an environment file to load with it (by specifying [-e envfile]). An environment file specifies a camera
position and lighting information. In addition, you can also specify a shading model to use (using [-s modelname]) when ray tracing. There are 6 shading models here (each is listed with its command line argument):
- Flat shading [-s f]
- The color of a point is based on the diffuse color of the object.
- Normal shading [-s n]
- The color is based on the normal vector at the point on the object.
- Ambient shading [-s a]
- The color is based on the ambient illumination term and the object's emmision term.
- Local shading [-s l]
- Ambient shading is performed. In addition, diffuse and specular terms are added for each light source.
- "Shadows" shading [-s s]
- This is the same as local shading, except that shadow rays are spawned to determine how visible the point is from each light source.
- Recursive shading [-s r]
- Full-blown-hang-on-to-your-pants recursive shading. In addition to performing "shadows" shading, reflected and transmitted radiance is collected by recursive calls.
There are other arguments as well. For a complete listing, use the [-help] argument.
There are 2 buttons on the left to invoke your ray tracer, once you are up and running: The "*" button invokes the ray tracer without debugging (where each raster is displayed as it is rendered). The "D" button invokes the ray tracer with debugging (where each pixel is displayed one at a time, as it is rendered).
Ok. Where do I start?
For this assignment, you will only be editing 3 files: EyeRay.C, RayCast.C, and Shade.C ! You are encouraged to look at the other files to understand how the
code works, but you will only need to modify them if you are implementing
additional features for extra credit.
As this is a large application, it may be necessary for us to
release changes to the code. This is why it is important for you to
confine your work to the specified files. If you need to change any
other files when adding additional features for extra credit, be sure
that you are happy with the current version of the code. We cannot
guarantee that our changes will be compatible with yours.
Your task is to fill in the following subroutines (each is listed with the file in which it resides):
| ComputeEyeRay() | in EyeRay.C |
| IntersectDisk() | in RayCast.C |
| IntersectCylinderBody() | in RayCast.C |
| IntersectConeBody() | in RayCast.C |
| ReflectionDirection() | in Shade.C |
| TransmissionDirection() | in Shade.C |
| ReflectionRadiance() | in Shade.C |
| TransmissionRadiance | in Shade.C |
| Shadowing() | in Shade.C |
| DiffuseRadiance | in Shade.C |
| SpecularRadiance | in Shade.C |
For a brief code walkthrough, which will help in figuring out what each of these subroutines does, look at the bottom of this page.
NOTE: At the top of each subroutine you will be editing, there will be
a comment starting with "AAA" which clearly specifies the task. You can obtain a
quick listing of where these comments are by calling:
athena% grep AAA *.C
How do I know if my code works?
In addition to coding carefully, thoughtfully, and correctly, you can use our test files :)
We have provided 8 different test files for your testing pleasure. Test files 5 through 7 also have environment files which they should be loaded with. That way, you can compare your output with your friends :)
What else do I need to know?
We expect your ivray to correctly ray-trace all of the included test Inventor files, from any view point.
We may also test it against several more challenging Inventor objects.
Turn in your modified EyeRay.C, RayCast.C, and Shade.C, your stripped executable ivray, and any other
.C or .h files you modify. We will test your source for compilation using the assignment Makefile. Thus,
you must include any files that you have modified (we will supply unmodified files from the assignment source).
This assignment is due 5pm Friday, 17 October 1997.
What if I wanna add additional features?
There are countless features you can add to the ray tracer for extra credit. Some ideas
have been given to you, marked with "CCC" in comments in the code. What
and how much you add is completely up to you, and we encourage you to add
features that we have not specifically suggested.
If you do add any "extra" features, make sure to tell us about them
by turning in a file "EXTRA", and an executable exivray!
How does all this code work?
Click here for a brief code walkthrough.
Don't Forget: