Search tldr

Ray Tracing in One Weekend

A hands-on C++ tutorial for building a compact but capable path tracer from scratch: rays, geometry, Monte Carlo sampling, materials, camera control, and depth of field. It prioritizes clear baseline implementations that produce visually rich renders and can be extended into a fuller renderer.

Share

Ray Tracing in One Weekend

Author: Peter Shirley, Trevor David Black, Steve Hollasch | Published: 2025-04-25 | Generated: 2026-03-07 | Domain: raytracing.github.io
Tags: ‘#raytracing’ ‘#pathtracing’ ‘#cpp’ ‘#computergraphics’ ‘#rendering’ ‘#montecarlo’


TLDR

This introductory book builds a CPU path tracer step by step, using C++ but emphasizing rendering concepts that transfer to other languages. It progresses from PPM image output and vector math to ray/object intersections, recursive Monte Carlo light transport, diffuse/metal/glass materials, antialiasing, configurable cameras, and defocus blur. The result is intentionally simple rather than production-ready, but its architecture provides a solid base for features such as BVHs, textures, lights, transforms, and volumetrics.

Key Takeaways

  • Incremental renderer construction: The tutorial starts with plain-text PPM output, then adds vec3, rays, sphere intersections, surface normals, a hittable abstraction, and a camera class to create an extensible rendering core.
  • Path-tracing fundamentals: Per-pixel random sampling reduces aliasing, while recursively scattered rays approximate indirect lighting; samples_per_pixel controls sampling quality and max_depth caps bounce recursion.
  • Numerical robustness matters: The implementation uses hit intervals, ignores intersections below t = 0.001 to prevent shadow acne, rejects near-zero random vectors, clamps final intensities, and applies gamma-2 correction via square root.
  • Material models: Lambertian materials scatter around the normal and attenuate by albedo; metals use vector reflection plus optional fuzz in the 0–1 range; dielectrics use Snell’s law, total internal reflection, and Schlick’s reflectance approximation.
  • Final reference scene: The cover-style render uses a 1200-pixel-wide image, 500 samples per pixel, a maximum depth of 50, hundreds of randomized small spheres, a 20° vertical FOV, and a 0.6° defocus angle. The repository’s development sample reduces samples per pixel to 10 for practical iteration time.

Images & Media

Keep reading