Personal tools
Views
Ray tracer
From PagodaWiki
Jason Kraft and Kent Sutherland's Computer Graphics 2 (20083) project page.
Contents |
Setting the Scene
So you have the original image below by Turner Whitted, who developed the original ray tracing algorithm in 1979.
Then you have our quick and easy Maya 2009 render using Mental Ray. You'll notice some issues which we were honestly too lazy to fix, such as there being no refraction in the glass sphere, a not-so-convincing chrome material, and something funky going on with the shadows (I think Turner cheated; how in the world can the shadow from a point light be smaller than the object?). Anyhow, we will base the setup of our ray tracer on what we discovered from reproducing the scene in Maya.
Object attributes in Maya units (We have provided the location of the center of each object, but since objects were scaled to get the correct proportions, sizes are in Maya units, where scale 1 is equal to 1 Maya unit, rather than dimensions like heigh and width):
Chrome Sphere
translate = {-0.172, 1.333, 0.006}
scale = 0.806
Glass Sphere
translate = {-1.177, 2.124, 1.269}
scale = 1
Plane
translate = {-0.172, 1.333, 0.006}
scale = {10.945,1,69.975}
Camera
position = {0.979, 2.001, 6.601}
look at = {1.099, 1.817, -0.242}
up = {0.980, 4.000, 6.547}
Point Light
translate = {1.451, 6.547, 4.129}
We also stuck in an ambient light in order to soften the spheres' shadows, which would occur due to blue bounce light from the atmosphere.
Camera
In this stage, we manually setup the projection and cast rays into the scene, transforming them through the correct matrices in order to compute object intersections. We added intersection tests for 3 primitive types: sphere, plane and cylinder.
The original scene after the projection and camera have been setup. Ray intersections are calculated for spheres and planes.
(Extra) Super sampling is shown in the right image. We cast additional rays around the main pixel and average their values in order to blur the boundaries of objects and thus provide a sort of anti-aliasing.
(Extra) Here we added support for ray intersections on cylinders. It tests both the sweep and the top and bottom caps.
Basic Shading
In this stage, we implement basic Phong shading for all of the primitives. It involves solving an equation that accounts for an ambient, diffuse and specular lighting term for each intersection of a surface. The lights are point lights, and they also cast shadows by spawning a shadow ray at each point of intersection and computing whether or not another object is between the shadow ray and the light source. Additionally, we added support for more than one light source.
The original scene with Phong shading.
(Extra) Here we extended our support for cylinders to work with Phong shading, and factor in contribution from multiple light sources into the final pixel color.
Procedural Shading
This step focuses on mapping a procedural texture to object or texture space. We had to figure out the relationship between a ray intersection point in world space and the corresponding location relative to the plane.
The regular scene with a simple checkerboard texture.
The scene with all the bells and whistles, plus a new procedural texture: a Mandelbrot fractal.
Reflection
This step was really quick. Its purpose was to figure out how to do reflection, as in mirror surfaces and chrome. The idea is simple enough: recursively spawn rays reflected about the object's surface normal at each intersection point back into the scene in order to pick up reflected colors.
Here is the chrome ball reflecting the checkerboard below it. You get warping around the edges and several other interesting effects depending on the primitive shape that has reflective properties.
Transmission
Transmission required that at each intersection point, if the object exhibited a transmissive material attribute, to trace the ray's path through it like glass. Rays that intersect the glass sphere are allowed to continue into the object according to a reversed surface normal. We keep track of whether or not the ray is inside or outside (a simple parity test), and also account for the object's index of refraction.
You can see that although the checkerboard and the chrome ball are visible through the glass sphere, they are warped due to both the sphere's shape and its index of refraction.
Tone Reproduction
Ward's Perceptual Operator: 1 cd/m^2
Ward's Perceptual Operator: 1000 cd/m^2
Ward's Perceptual Operator: 10000 cd/m^2
Reinhard Photographic Operator: 1 cd/m^2












