A basic unoptimised ray-tracer to be used as an example for Optimisation.
This project can be most easily executed on any platform using Docker and VSCode DevContainers.
- Install Docker
- Install VSCode
- In VSCode, install the extension Dev Containers
- Open this project inside VSCode (the
.devcontainer
directory must be at the root of the project for the Dev Container to be recognised)
- Press
F1
, in the context menu typeDev Cont
... and in the proposed options, choose "Rebuild Container".
- VSCode will restart, building the Docker Image and starting the container.
- If the build fails, you may need to : 7.1 Consult the error logs to resolve the build problem on your platform 7.2 Switch to a different network (the school's network might be blocked or limited)
- If all goes well, you can open a new terminal in VSCode. The prompt should read
root@....:/app
:
Navigate into the build
directory:
cd build
Run cmake
to create the build configuration:
cmake ..
Build the raytracer:
make
Run the raytracer:
./raytracer
Each time you modify the project structure by adding a new class to compile, adding a compile option, etc. you need to update the build configuration by running:
cmake ..
The raytracer uses an input JSON file (as the first argument) to specify the scene to be rendered.
You can either specify the path of the output file as the second argument. Otherwise the generated file is image.png
.
The following examples are provided in the the folder scenes
.
./raytracer ../scenes/two-spheres-on-plane.json
./raytracer ../scenes/two-triangles-on-plane.json
./raytracer ../scenes/sphere-galaxy-on-plane.json
./raytracer ../scenes/iso-sphere-on-plane.json
./raytracer ../scenes/monkey-on-plane.json
./raytracer ../scenes/all.json