Skip to content
Copied!

1. Raytracing in One Weekend

All 13 chapters of Week 1 are covered in order. The original book is written in C++11, and understanding the differences between C++ and Rust is one of the key learning axes of this document. Topics include: representing return values with Option<T> instead of output parameters; using Arc<dyn Trait> instead of shared_ptr; defining pure virtual functions as traits; operator overloading; expression-oriented control flow; and Rust's ownership and borrowing rules, all explained alongside comparisons with their C++ equivalents.

Complete13 chaptersStarted:
  1. 1. Overview

    Ray Tracing in One Weekend is an introductory book on ray tracing written by Peter Shirley, Trevor David Black, and Steve Hollasch. This booklet builds up a phy…

  2. 2. Output an Image

    This chapter explains the PPM image format and presents the first rendering: a simple color gradient. The C++ code outputs in PPM format to standard output. How…

  3. 3. The vec3 Class

    The original book defines a vec3 class in C++ that is used for colors, positions, and directions alike. In this document, we implement it as a Rust struct. Beca…

  4. 4. Rays, a Simple Camera, and Background

    This chapter implements the heart of a ray tracer: casting a ray and computing its color based on the direction it travels. A ray is mathematically described by…

  5. 5. Adding a Sphere

    This chapter places the first object in the scene: the simplest 3D shape, a sphere. We derive the ray–sphere intersection test mathematically and color the hit…

  6. 6. Surface Normals and Multiple Objects

    In the previous chapter we painted the sphere silhouette a flat red. This chapter uses surface normal vectors to visualize the sphere's surface in color. We als…

  7. 7. Antialiasing

    The scene from the previous chapter is complete, but looking closely at the sphere's outline you can see jagged "staircasing" artifacts. This is because each pi…

  8. 8. Diffuse Materials

    This chapter implements diffuse materials (matte materials). A diffuse material absorbs light while scattering it in random directions. Three implementations ar…

  9. 9. Metal

    This chapter implements metal materials (specular reflection). To do that, we first introduce an abstract interface for materials and encapsulate the scattering…

  10. 10. Dielectrics

    This chapter implements dielectric materials (transparent objects such as water, glass, and diamonds). When light hits a dielectric, some of it reflects and the…

  11. 11. Positionable Camera

    This chapter extends the camera to allow free positioning and orientation. Until now the camera was fixed at the origin pointing in the negative Z direction. We…

  12. 12. Defocus Blur

    In this chapter we implement defocus blur — the photographic effect where objects in front of or behind the focal plane appear blurred, commonly known as depth…

  13. 13. Where Next?

    In this chapter we implement the final scene of Ray Tracing in One Weekend — the cover image of the book, bringing together every technique developed in Week 1…

  14. 13. Where Next? — High-Quality Version

    ← Back to standard version (13 Where Next?) The high-quality version uses the full 22×22 grid from the original book, placing more small spheres deep into the s…

  15. Supplement: Native Parallel Renderer

    All of our implementations so far have been designed to run as WebAssembly (WASM). Because WASM runs single-threaded and synchronously, rendering the final scen…