Ray Tracer From Scratch in C

From Scratch, in C


I started this project with one goal: Hand-roll everything. My Ray Tracer is really inefficient, but it was an invaluable learning experience.


The final demo render took 2 minutes.


Current Features


  • Spheres and Planes
  • Point Lights, Directional Lights, and Sphere Lights
  • Lambertian & Specular Reflection
  • Refraction & Refractive Index
  • Soft shadows
  • MSAA


Under the Hood


And here’s some cool algorithms and data structures I implemented:

  • Enum-Union Struct to chain different struct types into one list
  • This was tedious, I yearned for C++
  • Vector Math
  • Ray-Plane & Ray-Sphere Intersection
  • Sum of Lambertians
  • Camera rig
  • Frame buffer that renders to the screen in square-sized chunks

Check out the source code on Github!

thumbnail.png displaying-gradient-1.png