Skip to main content

Ray Tracing in One Weekend

v4.0.1

Peter Shirley's beloved educational book series that guides readers through building a ray tracer from scratch in C++

Ray TracingPath Tracing
C++
CC0-1.0
Active
CPU
Stars
9.5k
Latest Release4.0.1
Release DateAug 2024
Contributors45
Forks900
At a Glance
Technique
Ray Tracing, Path Tracing
Language
C++
License
CC0-1.0
Platforms
Linux
macOS
Windows
GPU Support
No
CPU Support
Yes
Scene Formats
Hardcoded
Output Formats
PPM
First Release
Jan 2013
Latest Release
4.0.1 — Aug 2024
Best For
Absolute beginners learning ray tracing fundamentals, CS students in introductory graphics courses, and self-taught programmers wanting a hands-on weekend project that builds real understanding

Development Activity

Commit activity data is not available for this renderer.

9.5k
Stars
4.0.1
1 year ago
45
Contributors
View on GitHub

Overview

Best for

Absolute beginners learning ray tracing fundamentals, CS students in introductory graphics courses, and self-taught programmers wanting a hands-on weekend project that builds real understanding

Not ideal for

Production rendering, research requiring advanced features, benchmarking, or any use case requiring performance, scalability, or diverse scene formats

Strengths

  • Arguably the most successful educational resource in computer graphics — has introduced hundreds of thousands of programmers to ray tracing through clear, incremental, hands-on implementation
  • Zero-dependency approach means anyone with a C++ compiler can follow along with no package managers, build systems, or external libraries, lowering the barrier to entry to near-zero
  • Three-book progression takes readers from basic ray-sphere intersection to Monte Carlo importance sampling, covering both practical implementation and mathematical foundations
  • CC0 (public domain) license means the code can be freely used, modified, and incorporated into any project without any restrictions — commercial, academic, or personal
  • Actively maintained with periodic updates adding corrections, improved explanations, and modern C++ practices

Limitations

  • Not a production renderer — the resulting code is intentionally simple and pedagogical, lacking optimizations like SIMD, GPU acceleration, and denoising that production renderers require
  • Single-threaded, CPU-only design means rendering any non-trivial scene takes minutes to hours — performance is deliberately not a goal
  • No scene description format — scenes must be authored directly in C++ code, which limits practical use beyond learning exercises
  • Outputs only PPM images, requiring conversion for modern use, though this simplicity is deliberate to avoid I/O library dependencies
  • Limited material system compared to full renderers — covers Lambertian, metal, and dielectric but not the full range of BSDF models used in research or production

Background

Ray Tracing in One Weekend is a three-book series by Peter Shirley (later co-authored with Trevor David Black and Steve Hollasch) that has become the most widely used introductory resource for learning ray tracing. Originally self-published as PDFs around 2013, the series is now freely available online and covers building a complete path tracer incrementally: Book 1 introduces ray-sphere intersection, antialiasing, diffuse materials, metals, dielectrics, and defocus blur; Book 2 adds motion blur, BVH acceleration, textures, lights, and volumes; Book 3 covers Monte Carlo methods, importance sampling, and PDFs.

The code is intentionally minimal — no external dependencies beyond a C++ compiler — and builds from zero to a functional path tracer that produces correct global illumination. Scenes are constructed directly in C++ code, and output is in PPM format. The design choices prioritize pedagogical clarity: the code is single-threaded and CPU-only, with no acceleration structures until Book 2. This deliberate simplicity means the reader can trace every line of code and understand exactly what the renderer is doing.

The series has had an extraordinary impact on the computer graphics community. Countless professional graphics engineers cite these books as their entry point into rendering, and they are assigned reading in university computer graphics courses worldwide. The CC0 (public domain) license means the code can be freely used, modified, and incorporated into any project. Peter Shirley, an NVIDIA Distinguished Scientist and co-author of the Fundamentals of Computer Graphics textbook, continues to maintain and update the series with corrections and modern C++ practices.

Quick Start

git clone https://github.com/RayTracing/raytracing.github.io && cd raytracing.github.io && cmake -B build && cmake --build build

Community & Resources

Paper & Citations

Performance Benchmarks

No benchmark data available for Ray Tracing in One Weekend yet.

Benchmarks will be added as more renderers are tested across our standard scene suite.

Learn about our methodology