Ray Tracing Project

Ray Tracing Project

The image created by my ray tracer.
The image produced by my ray tracer.

My first-ever computer programming class was an introduction to Java by Dr. Jeremy Frens. The final project was to write either a simple game or a simulation and present it to the class. Instead, I chose to build an object-oriented ray tracer.

I built this program in over a month (probably well over 100 hours). It is neither elegant nor optimized, but I am proud of having done it with only a semester of formal programming experience and no background in computer graphics. I challenged myself with a fun and engaging goal, and then I accomplished it.

Download

I haven't had the time to make a user interface so that you can create your own scenes and textures. Instead, I just have a demo scene in a JAR file. You can download it by clicking the button below. If you have Java installed on your computer, you can run it simply by opening it like you would any other program. Disclaimer: this was written before I knew much about optimizing code, so it runs slowly.

What Is Ray Tracing?

Ray-tracing is an advanced technique used in computer graphics to attain the best visual quality. To create an image in the virtual world, the computer traces rays of light backwards from a virtual eye through each pixel of the screen to determine what color each pixel should be. The computer checks whether that ray hits any objects or surfaces in the virtual world. If it does, it checks what color surface should be, and how reflective it is, how well-lit the surface is at the intersection point, and several other pieces of information. If the surface is reflective, then the computer traces the reflected ray beyond to see what color reflection this new ray will give the original ray.

The math behind ray tracing is fairly complicated. For starters, a ray tracer has to compute a reasonable viewing geometry and set up a bunch of mathematical objects in the virtual world. Each light source has to have a position, an orientation, a color, an intensity, and other properties. Each object needs a surface texture that includes the color, reflectivity and transmissivity at each point on the surface, which involves knowledge of computer graphics. The actual ray-tracing itself is complicated by recursive algorithms that sum up the contribution from all rays to calculate the final color of each pixel in the final image. All of these steps involve heavy knowledge of vector algebra and computer graphics. Fortunately, I had just learned about vectors in my Calculus 2 course....


The content of this page was last modified on Thursday, 17 February 2022 16:53:38 (MST).

I wrote the HTML and CSS for this website by hand in order to teach myself web design. It may not be the flashiest web page, but I am proud of it!