top of page
Ray

Context

In Fall 2018, I took an Intro to Computer Graphics class. Our final individual project was to create a fully functioning ray tracer, capable of rendering spheres, cubes, cylinders, and cones through implicit equations.

DEMO

Why is this important?

Ray tracing as a rendering tool for computer graphics is able to construct amazingly realistic graphics.  As such, being versed in how ray tracing functionally works is a huge step towards being able to contribute to modern computer graphics works.  

​

Additionally, all objects and scenes you see in this portfolio piece are hand placed and displayed via various implicit shape equations and calculations.  

No elements were dragged and dropped -- everything was manual!  The coming sections detail what those calculations are as well as the process of figuring out ray tracing algorithmically!

Initial problems

and Solutions

Ray tracing functionally was difficult to figure out; how does one "shoot out rays" and try to determine the color of a pixel on the screen?

​

To represent the process, ray tracing is:

1.) For each pixel on the screen

2.) Shoot out a "ray" through the pixel from the camera

3.) This ray checks for intersections with any objects 

in the scene

4.) The closest intersection yields the displayed object

5.) Color the pixel depending on the object's settings

​

The hardest part was figuring out what an "object" represented -- how do we represent an "object" as something a ray could collide with?

 

The solution ended up being Implicit Equations for each of the shapes.  Essentially I represented each object (sphere, cone, cylinder, cube) as an equation, and returned the distance a ray traveled to intersect with the object.

​

At this point, we now are able to represent each object on the screen and color them correctly using the following equation (which takes into account our passed in lights):

​

​

​

​

Which yields the following:

equation.png
Griffin Beels - Computer Graphics Intersection Shapes

Shadows, Reflection, and Texture Mapping

If you watched the demo I linked above, you'll realize the above image isn't the final product.  We still have to figure out shadows, reflection, and texture mapping.

​

First, I determined how to handle shadows. This entailed determining when an object was blocking a ray's path from each light source.  The solution ended up being skipping the shadow portion of the equation if an object is blocking a ray from the the light source.  This means that if, say, the sphere below is blocking light from landing on the platform, light will not contribute to those pixels on the platform.  Shadows yield the following:

Griffin Beels - Computer Graphics Shadows

The most difficult portion of the project for me was actually reflection. This is because it was done recursively -- by shooting out a ray from the point of intersection instead of from the camera.  How to factor in this reflection is accounted for in the above equation, but actually determining values was structurally hard.  I added multiple variables to the function calls for each step to make sure it worked recursively. If an object is reflected in another object, the pixel color changes to reflect that. With both shadows and reflections, the scene now looks like: 

Griffin Beels - Computer Graphics Shadows & Reflections

Finally, we need to apply textures to each object.  The hurdle of this feature was determining how to convert each objects position into a texture map position. In order to do this, we simply created formulas for each object that takes in an x,y,z position and converts it into a given picture's u,v coordinates.  This allows every pixel of an object to correspond to a pixel on the texture picture. With everything added together, we get:

Griffin Beels - Computer Graphics Shadows & Reflections & Texture Mapping

Conclusion / Takeaways

Ray tracing is an extremely powerful tool for computer graphics that can create incredibly defined and realistic images.  However, ray tracing is also computationally expensive.  As a result of this project I have learned the following:

​

1.) How to ray trace for cubes, spheres, cylinders, cones.

​

2.) How to determine shadows, texture mapping, and reflections for these shapes

​

3.) How to incorporate point and directional lighting into object coloration

​

4.) Ray tracing constructs great images at the cost of speed.

​

​

Now I can create any scene I want and ray trace it!  Here's another example:

[only point & directional lights]

voltorb_one.png

[shadows]

voltorb_two.png

[texture mapping]

voltorb_three.png
bottom of page