This is a C++ implementation of a raytracer, a computer graphics technique for simulating the way light interacts with objects to generate realistic images. This raytracer supports features like basic shapes (spheres), reflections, shadows, and basic materials.
- Sphere primitive
- Materials (Matte, Specular, Dielectric)
- Shadows
- Reflections
- Anti-aliasing
- Depth of Field
- PNG output
- Multi-threading
- C++17 or higher
- CMake (for building)
-
Clone this repository:
git clone https://github.com/PotatoPresident/Ray-Tracer cd Ray-Tracer
-
Create a build directory and generate build files with CMake:
mkdir build cd build cmake ..
-
Build the project:
cmake --build .
./raytracer.exe
./raytracer.exe <image_width> <image_height> <samples_per_pixel> <max_depth> <threads>
image_width
: Set the width of the output image (default: 100).image_height
: Set the height of the output image (default: 100).samples_per_pixel
: Specify amount of samples for each pixel (default: 10).max_depth
: Set the maximum amount of times a ray can bounce (default: 10).threads
: Set the number of threads to use for rendering. Set to 0 to use maximum suggested (default: 0).
The scene file is a text file containing a description of the objects and their properties. Here is an example:
./raytracer.exe
./raytracer.exe 1920 1080 100 50 0
This project was inspired by Peter Shirley's "Ray Tracing in One Weekend" series.
This project is licensed under the MIT License - see the LICENSE file for details.