Skip to content

Latest commit

 

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Ray Tracer with Photon Mapping

A classic Whitted-style ray tracer with global illumination via photon mapping, written in C++.

Example Images

cornell sphere

cornell teapot

Features

  • Whitted Ray Tracing
  • Spheres and Polymesh objects
  • Point lights
  • Shadows
  • Transparent and reflective materials
  • Phong shading
  • Phong interpolation for smoothing meshes
  • Photon mapping (global and caustic) using kd-trees and k-NN searches
  • Indirect diffuse illumination (colour bleeding) via global photon map
  • Glass tinting for coloured caustics
  • Multi-object scenes
  • Multi-light scenes
  • Antialiasing
  • Gamma correction

Installation and Running the Ray Tracer

Installation

Mac

git clone https://github.com/CarolineMillan/raytracer_cpp.git
cd raytracer_cpp
chmod +x Scripts/Setup-Mac.sh
./Scripts/Setup-Mac.sh

You will be prompted for your password to install raytrace to /usr/local/bin.

Linux

git clone https://github.com/CarolineMillan/raytracer_cpp.git
cd raytracer_cpp
chmod +x Scripts/Setup-Linux.sh
./Scripts/Setup-Linux.sh

You will be prompted for your password to install raytrace to /usr/local/bin.

Windows

git clone https://github.com/CarolineMillan/raytracer_cpp.git
cd raytracer_cpp
Scripts\Setup-Windows.bat

Requires make to be available first — install via Git for Windows, MSYS2, or Chocolatey (choco install make). After running the script, raytrace.exe will be copied to C:\Windows\System32.

NB: I don't have a Windows machine to test this on, so please let me know if it doesn't work.

Running

The raytracer must be run from the project root so that it can find the mesh files:

cd raytracer_cpp
raytrace

The output will be saved as a .ppm file in the images/ folder. To convert to .png, use ImageMagick:

magick images/<filename>.ppm output.png

or upload the .ppm to convertio.

Acknowledgements

  • My lecturer Ken Cameron provided the base code that I worked off for this project, and I've left his comments in
  • I used The Cherno's project template to structure the project
  • kdtree.h was AI-assisted, the rest is my own work

License

This software is available as open source under the terms of the MIT license.

Future Plans:

  • Importance sampling (currently hard coded)
    • Caustic photons
    • Indirect global photons
  • A CLI
  • Store photon maps between renders
  • Add some features from Peter Shirley's ray tracing in one weekend
    • BVH
    • area lights
    • perlin noise
    • improve camera model
    • Volumetric scattering / participating media

About

Photon Mapping Whitted Ray Tracer in C++

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages