Skip to content

A C++ ray tracer based on the book series Ray Tracing in One Weekend

License

MIT and 2 other licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.Catch2
Unknown
LICENSE.cpplint
Notifications You must be signed in to change notification settings

JuJuz1/RayTracer

Repository files navigation

RayTracer

A learning project following Peter Shirley's book series Ray Tracing in One Weekend (Version 4.0.2, 2025-04-25)

The goal for the first book is to create a C++ ray tracer which can create good-looking images


Table of Contents

  1. Current features
  2. Example renders
  3. Running Locally
  4. Tools

Current features

  • A brute-force raytracer in C++23
  • Outputs images in P3 PPM format
  • Some command line arguments (will probably add more)
  • Progress indicators while rendering
  • Only supports spheres as shapes at the moment
  • Many randomized properties to provide unique renders each time
  • Multithreading support for significantly faster renders

Example renders

Image properties:

  • width: 1200

  • height: 675

  • samples per pixel: 500

  • max depth: 50 An example of a final render

  • samples per pixel: 100 An example of a final render

Running Locally

Prerequisites

  • A C++23 (or later) compatible compiler (GCC, MSVC or Clang)
  • CMake (version 3.1.0 or later recommended)

Build Instructions

  1. Clone the repository
git clone https://github.com/JuJuz1/RayTracer.git
cd RayTracer
  1. Build with CMake
cmake -B $(your_build_directory_name) # e.g. cmake -B build
cmake --build $(your_build_directory_name)
# for optimized builds
cmake --build $(your_build_directory_name) --config Release
  1. Run the program

You can specify the number of threads to use, default is 1. The default output file is image.ppm

./$(your_build_directory_name)/Release/inOneWeekend [num_threads] [output_filename.ppm]

There are many ways to view the created P3 PPM images. I found it easiest to use this website: PPM Viewer

Tools

Third-party

Cpplint

This project includes a copy of cpplint.py. See License

To verify that the source files comply with most of the cpplint checks run:

./run_cpplint.sh

Catch2

This project uses the Catch2 framework for testing the application. See License. The test cases are built alongside the raytracer library. To run the tests it is very similar to running the application.

./$(your_build_directory_name)/Release/tests

About

A C++ ray tracer based on the book series Ray Tracing in One Weekend

Topics

Resources

License

MIT and 2 other licenses found

Licenses found

MIT
LICENSE
Unknown
LICENSE.Catch2
Unknown
LICENSE.cpplint

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages