This is a complete hand-made re-implementation of the C++ InOneWeekend ray-tracer implementation (an amazing resource!).
The default rendering produced is
There are multiple implementations provided:
- single-threaded
- multi-threaded
- the boilerplate for running the CUDA version is present. However, most of it is missing (as it is your job to implement it in the project)!
It uses single-file public domain (or MIT licensed) libraries for C/C++.
The CPP renderer that you get, on the left. On the right, the expected result using CUDA
To build your project, start by running
mkdir build
cd build
cmake .. --fresh -G 'Unix Makefiles' -DCMAKE_EXPORT_COMPILE_COMMANDS=1 && cp compile_commands.json ..
make -j4This should create the required Makefile using CMake and compile it using 4 threads. You can then execute the CPP version using
./302_raytracerRebuilding after changing files is simply (for the CUDA renderer), something like:
make && echo "2" | ./302_raytracerInstall extension clangd from LLVM, for linting and formatting (the formatting options are present in the .clangd-format fil and the options for the linting are in .clangd).
This is all you need ! Please don't install MS C/C++ plugin, it does not work well with NVidia stuff.
- There are tasks created in the
.vscodefolder that can be launched withCTRL+sudoShift+P→ Tasks and then you can build and run. You can even set up key bindings for that. - Otherwise, run everything from the command line.
The first goes fast, the second has debug information. To compile each version, see (README_BUILD.md).
This project uses Doxygen to generate comprehensive API documentation from the code comments. The documentation includes:
- Class hierarchies and inheritance diagrams
- Function call graphs and caller graphs
- Detailed API references
- Mathematical explanations for ray tracing algorithms
Install Doxygen and Graphviz (for generating diagrams):
sudo apt-get install doxygen graphvizSimply run:
./generate_docs.shOr manually:
doxygen DoxyfileThe documentation will be generated in the docs/ directory:
- HTML documentation:
docs/html/index.html(open this in your browser) - LaTeX documentation:
docs/latex/(can be compiled to PDF)
To view the HTML documentation:
xdg-open docs/html/index.htmlOr simply open docs/html/index.html in your favorite web browser.
This work is licensed under a Creative Commons Attribution 4.0 International License.
Author: Pierre-André Mudry


