Alexander Aseme
GitHub IconLinkedIn Icon

Simple Ray Tracing

This is a basic CPU ray tracer capable of rendering 3D scenes composed of triangles and spheres with lighting and shadows. The ray tracer supports Phong shading, interpolated vertex normals, per-light visibility via shadow rays, and global ambient lighting. It renders still images at 640×480 resolution using a camera with a fixed field of view. The entire pipeline was implemented on the CPU without shaders or OpenGL rendering logic, apart from final image display. This project demonstrated core principles of ray casting, geometric intersection, and physically based lighting models.

The ray tracer was built in C++, using a custom pipeline to simulate realistic lighting. Rays were traced backward from each pixel to compute intersections with spheres and triangles, where lighting was evaluated using the Phong reflection model. Vertex attributes such as normals and material properties were interpolated using barycentric coordinates, allowing for smooth shading on triangles. Shadow rays were used to compute per-light occlusion.

Output scenes were defined in plain-text description files, and results were written directly to screen or JPEG images.

Key Features

  • Full CPU ray tracing with no GPU rendering
  • Triangle and sphere intersection
  • Per-light Phong shading with smooth interpolation
  • Shadow ray casting for hard shadows
  • Configurable global ambient lighting
  • Scene loading from custom .scene files
  • 640×480 image output with optional JPEG saving

Extra Credit Features

  • Recursive reflections with depth control
  • Randomized supersampling for anti-aliasing
  • Soft shadows via multi-sample area light simulation

Technical Details

  • Language: C++
  • Special Skills: ray-surface intersection math, ray tracing, barycentric interpolation

Gallery

Test Scene 1
Test Scene 1 - anti-aliasing, soft shadows, recursive reflection
Test Scene 2
Test Scene 2 - anti-aliasing, soft shadows, recursive reflection
Snow Scene
Snow Scene - anti-aliasing, soft shadows, recursive reflection
Spheres Scene
Spheres Scene - anti-aliasing, recursive reflection
Toy Scene
Toy Scene - basic functionality
Table Scene
Table Scene - basic functionality