CS 148 Fall 2012, Assignment 9: Ray Tracing

Ben Mildenhall


1024 by 512 pixels, 100 rays through each pixel, limit of 10 recursive bounces.

The above image uses most of my extensions to the ray tracing assignment given. In addition to the required features, I implemented All of these effects are demonstrated above except depth of field, which is more effective to use in a simpler scene. Each pixel had 100 rays shot through it, arranged in a 10 by 10 grid and jittered within their own cells. This allowed for the smooth area lighting effect. The slim rectangle and red ball are made of semi transparent materials which tint light refracted through them respectively blue-green and red using Beer's law. The high bounce depth of 10 maximum bounces allows for the rich and realistic appearance of the thin side of the rectangle facing the camera, since Snell's law allows for total internal reflection to take place. The reflection of the diffuse blue ball in the glass rectangle is more clear where the viewing angle relative to the rectangle is more shallow, using Schlick's approximation. The green mirrored column supporting the black diffuse ball is a parallelepiped and the table supporting the purple diffuse ball is made up of three cylinders.



768 by 512 pixels, 100 rays through each pixel, limit of 10 recursive bounces.
This image used area lights for soft shadows and contains many reflective and transparent surfaces and objects.



640 by 400 pixels, 100 rays through each pixel, limit of 12 recursive bounces.
This image used bounding volume hierarchies around the bowl and table to speed up performance. The bowl is a shape defined as the difference of two spheres of the same radius. As in the above two images, a high bounce depth allows for rays to reach the thin edge of the tabletop piece of glass through refraction and total internal reflection.




All images: 512 by 512 pixels (shrunk to 384 by 384 here), 100 rays through each pixel, limit of 3 recursive bounces.
These images demonstrate the effect of varying aperture size to achieve different depth of field in each image. The focus point stays at the front of the green ball in each picture. The first picture has no depth of field. Each image after that doubles the size of the aperture (respectively the apertures are 4, 8, and 16 pixels across when compared to a pixel on the image plane). A high bounce depth was not necessary since the scenes do not contain any transparent objects.


Here is the text input used to create the first image on the page. The nonstandard commands in use are Box, Cylinder, AreaLight, and TMaterial. Aperture and Focus are also in there but they are commented out (comments using #$@). The commented out PointLights are in the same positions as the centers of the AreaLights. The file has a lot of junky Materials and extraneous transformations lying around from testing which colors and locations would work the best in the scene.


Camera   11 26 12   0 0 1   6 8 4   27   2
Output   1024  512   CornellBox5area.png
BounceDepth   10
ShadowBias 0.005
$ Aperture 16

## Lights ##
AmbientLight   .05 .05 .05


@PointLight   1 1 9   .6 .6 .6
@PointLight   12 1 12   .4 .4 .4
@PointLight   1 12 12   .4 .4 .4

PushMatrix
Translate 1 1 9
AreaLight -1 -1 0   1 -1 0   -1 1 0   .6 .6 .6
PopMatrix
PushMatrix
Translate 12 1 12
AreaLight -1 -1 0   1 -1 0   -1 1 0   .4 .4 .4 
PopMatrix
PushMatrix
Translate 1 12 12
AreaLight -1 -1 0   1 -1 0   -1 1 0   .4 .4 .4 
PopMatrix

#  AreaLight   -2 9 -2   2 9 -2   2 9 2   1 1 1


#colors
#yellow   .90 .83 .12
#tan      .89 .84 .69
#brown    .52 .33 0.
#literbrw .72 .45 .15
#bluegrn  .84 1. .94
#lightblu .16 .82 1.
#purple   .54 0. .87
#orange   1. .45 0.


## The Box ##
PushMatrix
#Scale 2 2 2
# Floor
Material   .89 .84 .69   .89 .84 .69   0 0 0   0 0 0   0
Triangle   0 0 0   15 0 0   15 15 0
Triangle   0 15 0   0 0 0   15 15 0
PushMatrix
Translate 0 0 13
Triangle   0 0 0   15 15 0   15 0 0
Triangle   0 15 0   15 15 0   0 0 0
PopMatrix

# Left Wall
Material   .52 .33 0.   .52 .33 0.   0 0 0   0 0 0   50
Triangle   0 0 0   0 0 15   15 0 15
Triangle   0 0 0   15 0 15   15 0 0

# Right Wall
Material   1. .68 .15   1. .68 .15   0 0 0   0 0 0   50
Triangle   0 0 0   0 15 0   0 15 15
Triangle   0 0 0   0 15 15   0 0 15
PushMatrix
Translate 15 0 0 
Triangle   0 0 0   0 15 15   0 15 0
Triangle   0 0 0   0 0 15   0 15 15
PopMatrix
PopMatrix

Material 1 0 0   1 0 0  0 0 0  0 0 0 0
#Sphere   10 15 2   2

# Glass ball
TMaterial   .16 .82 1.   .16 .82 1.   0 0 0   0 0 0   0   1 .6 .6   2.
Sphere   2.3 6 1.5   1.5

PushMatrix
Translate .2 .2
Material 0 .4 0   0 .4 0   0 0 0    .7 .7 .7   50   0 0 0  1.8
Material   .9 .7 0   .9 .7 0   0 0 0   .7 .7 .7   0     .1 .1 .1    3.
# Material 0 .8 0   0 .8 0   0 0 0    0 0 0   50   0 0 0  1.8
Cylinder   2.5 9 0   2.5 9 .2   1.2
Cylinder   2.5 9 .2   2.5 9 1.35   .2
Cylinder   2.5 9 1.35   2.5 9 1.5   .9

Material  .54 0. .87   .54 0. .87  1 1 1   0 0 0   30
Sphere   2.2 9.1 2.01   .5
PopMatrix

TMaterial 0 .4 0   0 .4 0   0 0 0    0 0 0   50   .98 .98 1  1.3
Material 0 .4 0   0 .4 0   0 0 0    .8 .8 .8   50   0 0 0  1.8
#Cylinder  9 2.3 0  9 2.3  6   1

# Blue diffuse ball
Material   .16 .82 1.   .16 .82 1.   .6 .6 .6   0 0 0   50
Sphere   6 2 1.5   1.5
#Cylinder  6 2 0  6 2 6  1.8
#Box    8 4 0   4 4 0   8 8 0   8 4 4
#Compound i


# Mirror ball
Material   .1 .1 .1   0 0 0   0 0 0   .9 .9 .9   0
$Sphere   8 6.5 1.5   1.5
Sphere   8.5 8 1.8   1.8

$ Focus   8.5 7 1.5

# Pane
TMaterial   1 0 0   1 0 0   0 0 0   0 0 0   0     .7 .98 .9   1.5
PushMatrix
Translate   4.5 7 .01
#Rotate 0 0 10
Box   0 -2 0   .25 -2 0   0 2 0   0 -2 7
PopMatrix

Material   1. .45 0.   1. .45 0.   0 0 0   .1 .1 .1   0     .1 .1 .1    3.
Material 0 .4 0   0 .4 0   0 0 0    .5 .5 .5   50   0 0 0  1.8
PushMatrix
Translate 1 0 0
Box  8 1 0   10 1 0   8 3 0   8 1 4.5
Material  .2 .2 .2  .2 .2 .2   1 1 1   0 0 0   20     .7 .7 .7    2.
Sphere  9 2 5.5  1
PopMatrix