Wednesday, June 11, 2025

Raytracing in a Week

I have just finished some graphics projects and I want to point out how cool raytracing and raymarching are. If you are not familiar raytracing is a 3D technique where you model light rays and test their collisions with a scene per pixel. Raymarching is a 3D technique where you make increments of a light ray and test to see if it hits any thing in a scene. I know both of these approaches pretty well but I found an online book for raytracing called Ray Tracing in One Weekend that gave me a great foundation for 3D graphics. The book starts out with Larmbertian lighting which is really just a shaded sphere. Next Metal spheres then (my favorite) Dielectric spheres which look like glass. I will admit it took me more than two days to finish the book but the code was written in c++ and I converted it to JavaScript. The image below is generated from my code based on one of the last chapters (the big sphere in front is Metallic, the sphere behind it is Dielectric, and the smaller spheres in front are Lambertian.