Sunrise Ray Tracer

Final Project for CS488 by Jason P'ng

This project is called the sunrise ray tracer because the scenes featured all have a sunrise in the background. Also, as I was making the final scene, I could literally watch the sun rise. Ironically, I didn't implement any features to improve the lighting model.

New Primitives

Cones and Cylinders were added as new primitives to the modeling language. They are implemented using their parametric representations.

Texture Mapping

Texture mapping is implmented for spheres, cylinders, cones, and boxes. For spheres, geocentric coordinates are used. Cones and cylinders both use cylindrical coordinates. In the picture, the table is a box texture mapped with wood. Notice that the cylinder has different textures for different faces.

Reflection

Specular reflections are implemented by calculating the reflected ray from the intersection normal and recursively tracing the secondary reflected ray. To prevent infinite recursion, there is a maximum depth limit to how many times a ray can be reflected

Refraction

Refractions occur when a light ray is split upon hitting a transparent object into a reflected ray and a refracted ray through the object. Each transparent object has an index of refraction associated with it to determine how much light should bend based on how fast light travels through the material. To determine how much the light should be bent, Schnell's Law is used and to determine how much light is reflected vs refracted, and Fresnel's equations are used to determine how much light is reflected.

Bump map

Bump maps are implemented based on the method described by Blinn. Each bump mapped object has an associated height map which describes in UV coordinates how much the surface is raised. Using the surface tangents at a given UV coordinate, and numerically approximated derivatives for the height map, the normal based on the height map can be calculated.

Glossy Reflection

Glossy Refraction is achieved by perturbing the reflected randomly in x, y and z directions, and then renormalizing. For each reflected ray, 16 rays perturbed rays are created and averaged. The glossiness factor affects the range of values the ray can be perturbed in x, y, and z directions.

Glossy Refraction

Glossy Refraction is done in the same manner as glossy reflection, but perturbing the refracted rays instead. In the scene, the left sphere is no glossiness, the middle is slightly glossy, and the right is very glossy.

Hierarchichal Bounding Boxes

To speed up rendering time, all objects have bounding boxes that the ray checks for intersection first before doing the intersection calculation for the actual object. Furthermore, if an object has a hierarchy, then this object has a bounding box that includes all its children's bounding boxes. So the parent's bounding box will be checked before checking the children's bounding boxes. This has the most gains when there are hierarchical objects with many children objects that only appear in a portion of the screen.

Uniform Spatial Subdivision

To increase rendering time, a uniform grid is overlayed all objects in the scene, and the ray will traverse through the grid boxes one at a time. It only checks for intersections objects that are in the grid box it is in, so it reduces the amount of intersections that need to be calculated.

In the plots, the copies of the buckyball mesh is used, spread out around the scene.

Final Scene

Bonus Objectives

Beer's Law

Beer's Law describes how light is absorbed by a transparent object as it passes through. This creates a more realistic appearance to transparent objects.

Cel Shading

By changing the shaded values to use discretized lightness values, the shading of objects can take on a comic book appearance

Voxelization

Using the same grid from spatial subdivision, objects in a scene can be broken down into the voxels they inhabit. This was highly inspired by a previous CS488 final project.

Animation

With a lua script, 360 frames were created for each degree of rotation and later stitched together using an online gif creator.

Feature Lines

By sampling a disk of rays, creases and edges can be detected and dark lines are drawn to highlight those features. This method is from a paper by Choudhury and Parker