Skip to content

ISC-HEI/302_ray_tracer_stud

Repository files navigation

A simple - yet pretty cool - ray-tracer for CS302 HPC

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++.

Ray Tracer Output The Ray Tracer Output when the project is finished

The CPP renderer that you get, on the left. On the right, the expected result using CUDA

Using CMAKE to generate compilation scripts

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 -j4

This should create the required Makefile using CMake and compile it using 4 threads. You can then execute the CPP version using

./302_raytracer

Rebuilding after changing files is simply (for the CUDA renderer), something like:

Running

make && echo "2" | ./302_raytracer

Develop with VSCode

Install 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.

Running your project during development

  • There are tasks created in the .vscode folder that can be launched with CTRL+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.

Choosing RELEASE or DEBUG versions

The first goes fast, the second has debug information. To compile each version, see (README_BUILD.md).

Documentation

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

Prerequisites

Install Doxygen and Graphviz (for generating diagrams):

sudo apt-get install doxygen graphviz

Generating Documentation

Simply run:

./generate_docs.sh

Or manually:

doxygen Doxyfile

The 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)

Viewing Documentation

To view the HTML documentation:

xdg-open docs/html/index.html

Or simply open docs/html/index.html in your favorite web browser.

License

This work is licensed under a Creative Commons Attribution 4.0 International License.

CC BY 4.0

Author: Pierre-André Mudry

About

CPP raytracing template for ISC 302, to be ported to CUDA

Resources

Stars

Watchers

Forks

Releases

No releases published