Skip to content

Latest commit

 

History

History
69 lines (50 loc) · 2.31 KB

File metadata and controls

69 lines (50 loc) · 2.31 KB

CLAUDE.md

This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.

Project Overview

This is a C++ implementation of the "Ray Tracing in One Weekend" tutorial series, containing three progressive raytracing renderers:

  • rt-weekend: Basic raytracer (Ray Tracing in One Weekend)
  • rt-next-week: Enhanced raytracer with textures, motion blur, and acceleration structures (Ray Tracing: The Next Week)
  • rt-troyl: Monte Carlo pathtracer with advanced lighting (Ray Tracing: The Rest of Your Life)

Each directory contains a complete raytracer with shared header-only libraries for geometry, materials, cameras, and rendering utilities.

Build System

Uses CMake with C++23 standard. Build commands:

# Configure and build (from project root)
cmake -B build
cmake --build build

# Or using make directly in build directory
cd build && make

# Build specific targets
cmake --build build --target rt-weekend
cmake --build build --target rt-next-week  
cmake --build build --target rt-troyl
cmake --build build --target pi_calc

Running Renderers

Executables output PPM images to stdout:

# Render and save image
./build/rt-weekend > image.ppm
./build/rt-next-week > image.ppm
./build/rt-troyl > image.ppm

# Pi calculation utility
./build/pi_calc

Code Architecture

  • Header-only design: All core functionality in .h files for easy inclusion
  • Progressive complexity: Each tutorial builds on previous concepts
  • Shared utilities: Common math/utility headers across all three implementations
  • Modular materials: Separate material classes (lambertian, metal, dielectric, etc.)
  • Acceleration structures: BVH trees for fast ray-object intersection in advanced versions
  • Multi-threading: Thread pool implementation for parallel rendering

Key shared components:

  • vec3.h: 3D vector math and point operations
  • ray.h: Ray class for ray-object intersection
  • camera.h: Camera positioning and ray generation
  • material.h: Material properties and light scattering
  • hittable.h: Abstract interface for ray-intersectable objects

Development Notes

  • Uses .clangd config with modernize checks enabled
  • PPM format output for rendered images
  • Images render to renders/ directory
  • Sample scenes defined as functions in main.cc files