RAYTRACER

 Computer Graphics ✶ C++

December 2023

I. Introduction

Ray tracing is a technique used to render images by simulating how light rays interact with objects in a scene. Unlike traditional rendering methods that approximate lighting, ray tracing follows the path of light rays as they travel through a virtual environment, bouncing off surfaces, and passing through transparent objects.

My implementation of the ray tracing algorithm uses the Phong illumination model with three types of light sources (directional lights, point lights, and spot lights) and four primitive shapes (cubes, spheres, cylinders, and cones). Key features include shadows, reflections, and texture mapping.

II. Algorithm

A scene file is loaded and information about the camera, objects, and lights is parsed.

For each pixel in the image plane, a ray is generated that originates from the camera's position and passes through the pixel. 

Once an intersection is found, the the color of the surface at that point is computed using the Phong shading model. This takes into account the material properties of the object, the position and intensity of the lights, and the view direction.

→ to determine if the intersection point is in shadow, rays are cast from the intersection point to each light source. If these rays intersect other objects before reaching the light, the point is in shadow, and its color is adjusted accordingly.

→ if the object is reflective, a reflection ray is generated using the law of reflection, where the angle of incidence equals the angle of reflection. This ray is traced into the scene, and its contribution is added to the color of the pixel.

III. Results

Code available upon request--email me!