This project is an attempt at ray tracing, a rendering technique for generating an image by tracing the path of light as pixels in an image plane and simulating the effects of its encounters with virtual objects.
-
src/ray.cpp
: This file contains the main logic of the ray tracing process. It sends a ray for every pixel and checks for intersections with the defined objects (spheres and planes). Depending on the intersection results, it sets the color of the pixel. -
src/td.h
: This file contains the definitions of various structures used in the project, such as vectors (Vec3), rays (Ray), spheres (Sphere), planes (Plane), and colors (Color). It also includes the implementation of the dot product operation`` -
optional/equations_sphere_intersection
: This file contains the equation used to detect intersections between a ray and a sphere. The equation is a quadratic formula derived from the geometric definition of a sphere. -
Makefile
: This file contains the build`instructions for the project. It compiles src/ray.cpp into an executable named lulz. -
images/img.ppm
: Thi`` is the output image file generated by the ray tracer.
To use this project, follow these steps:
- Clone the repository to your local machine.
- Navigate to the project directory in your terminal.
- Run the command make to compile the project. This will create an executable named lulz.
- Run the executable with the command ./lulz. This will generate an image file named img.ppm in the images directory.
- Understanding the concept of rays and how they are used to simulate the path of light in a 3D scene.
- Learning how to detect intersections between rays and geometric objects (spheres and planes in this case).
- Implementing the dot product operation, a fundamental operation in vector algebra.
- Gaining experience with C++ and its features, such as structures and file I/O.
- Learning how to use a Makefile to automate the build process of a C++ project.
This project is kind of old and one of my first times using c/c++, however I still value it as a learning experience since I went into it head on and knew nothing about c/c++ at the time. The end result is really simple but I'm still proud of it. Maybe in the future I will revisit this project and add more features to it.