Primitives

4 primitives solids were implemented: cube, sphere, cone, and cylinder.

Constructive Solid Geometry

Constructive solid geometry was implemented, which allows primitives to be combined using the following 3 boolean operations: union, intersection, and difference.

Image idea from Wikipedia.

Texture Mapping

Textures can be applied to all 4 types of primitives. Note that the background and the table are textured cubes.

Party hat texture from here.

Soda can texture from here.

Ping pong ball texture from here.

Wood texture from here.

Marble texture from here.

Bump Mapping

A normal map of the earth has been applied to on top of an earth texture onto a sphere. The image was rendered twice with different lighting angles to more clearly show the normal mapping.

Earth texture and normal from here.

Reflection

Mirror reflection was implemented.

Refraction

Refraction was implemented. The following shows refraction with different indices of refraction.

Refractive Index = 1.1 Refractive Index = 1.3 Refractive Index = 1.5 Refractive Index = 2.0

Glossy Reflection/Refraction

Glossy reflection and refraction was implemented by randomly perturbing the reflected/refracted ray.

Glossy Reflection: Glossy Refraction: Glossy Transmission:

Soft Shadows

Soft shadows was implemented by perturbing the position of the light source by a random amount, and checking if there was anything between the surface and the light surface. Using a large sample size, we can get a reasonably accurate image.

Soft Shadows: Hard Shadows:

Grid Acceleration

Ray-object intersection calculations were accelerated by subdividing the scene into uniformly sized grids and precomputing which objects occupied which cells in the grid.

This was tested by generating n3 spheres in a cubic grid, with n spheres on the length, width, and height.

As seen in the chart above, the slope of the line of best fit for No Acceleration is 0.337, while the slope of the line of best fit for the Grid Accelerated program is 0.029, an 11x speed up.

Final Scene

The final scene uses all ray tracer features mentioned above. Note that the arc on the globe is generated using Constructive Solid Geometry, implemented as a sphere differenced with 2 cubes and another sphere.