small medium large xlarge

The Ray Tracer Challenge: A Test-Driven Guide to Your First 3D Renderer

by

Cover image for The Ray Tracer Challenge

The Ray Tracer Challenge

A Test-Driven Guide to Your First 3D Renderer

by

Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! It’s easier than you think. In just a couple of weeks, build a ray tracer that renders beautiful scenes with shadows, reflections, brilliant refraction effects, and subjects composed of various graphics primitives: spheres, cubes, cylinders, triangles, and more. With each chapter, implement another piece of the puzzle and move the renderer that much further forward. Do all of this in whichever language and environment you prefer, and do it entirely test-first, so you know it’s correct. Recharge yourself with this project’s immense potential for personal exploration, experimentation, and discovery.


Printed in full color.

Customer Reviews

Following in the footsteps of his book, Mazes for Programmers, Buck once again takes a challenging concept, presents it in an easy-to-understand format, and reminds us that programming can be both fun and rewarding.

- Dr. Sebastian Raaphorst

, Gemini Observatory

This is a problem domain that I’ve always wanted to get into but have struggled to find anything approachable for someone who doesn’t know or isn’t good at all with C or C++. This book is a godsend.

- Danielle Kefford

Software Engineer

This book is devious. Little by little, a test here and a test there, you’ll create an incredibly sophisticated ray tracing library. Because each change is so small, your ray tracer will sneak up on you. That’s the devious part: by the end you’ll have built an amazingly complex piece of software, but it will never feel difficult!

- Cory Forsyth

Founding Partner, 201 Created, Inc.

In The Ray Tracer Challenge Jamis Buck tames a difficult topic using an entertaining, practical approach that even the mathematically averse will enjoy. The testdriven approach challenges and rewards the reader with experiences and artifacts that remind even the grizzled software curmudgeon of the joyful moments in software development that inspired us to pursue engineering in the first place.

- Justin Ball

CTO, Atomic Jolt

Creating a ray tracer is a rite of passage that I recommend all developers endeavor to complete. Jamis does a great job presenting complex topics simply and allowing the reader to focus on the most interesting parts of the project. Working through this book is almost guaranteed to bring your programming skills up a notch.

- Jason Pike

Director, Software Engineering, Atlas RFID Solutions

The Ray Tracer Challenge is a delightful introduction to 3D lighting and rendering through ray tracing. Yes, there is math, but Jamis provides great examples, and the exercises illustrate concepts in a style that is way more fun than any math class I took in college!

- Matthew Margolis

Director, Software Engineering

Taking the Ray Tracer Challenge was so much fun. Starting with some short tests, you’ll create beautifully rendered images with just a little bit of math and code.

- Justin Weiss

Senior Software Engineer, Aha!

With this book, I can use what I learned at the university thirteen years ago, and it’s now fun! The Ray Tracer Challenge gave me back my joy for pet projects. I recommend it to everyone!

- Gábor László Hajba

Senior IT Consultant

One of the tricks to avoiding programmer burnout is to find a passion project. In this book, you’ll find exactly that: an awesome personal project that you can tackle regardless of your language background. Jamis’s The Ray Tracer Challenge shows us that the best passion projects are shared.

- Kevin Gisi

Senior UX Engineer

See All Reviews

Choose Your Format(s)

  • $47.95 In Stock

    Save $14.95 on the combo pack.

  • $37.95 In Stock
  • $24.95 In Stock
  • Ebooks are DRM free.

  • Ebook delivery options.

What You Need

Aside from a computer, operating system, and programming environment, you’ll need a way to display PPM image files. On Windows, programs like Photoshop will work, or free programs like IrfanView. On Mac, no special software is needed, as Preview can open PPM files.

Contents & Extracts

  • Getting Started
    • Who This Book Is For
    • How to Read This Book
    • Things to Watch Out For
  • Tuples, Points, and Vectors
    • Tuples
    • Operations
    • Putting It Together
  • Drawing on a Canvas
    • Representing Colors
    • Implementing Color Operations
    • Creating a Canvas
    • Saving a Canvas
    • Putting It Together
  • Matrices excerpt
    • Creating a Matrix
    • Multiplying Matrices
    • The Identity Matrix
    • Transposing Matrices
    • Inverting Matrices
    • Putting It Together
  • Matrix Transformations
    • Translation
    • Scaling
    • Rotation
    • Shearing
    • Chaining Transformations
    • Putting It Together
  • Ray-Sphere Intersections
    • Creating Rays
    • Intersecting Rays with Spheres
    • Tracking Intersections
    • Identifying Hits
    • Transforming Rays and Spheres
    • Putting It Together
  • Light and Shading excerpt
    • Surface Normals
    • Reflecting Vectors
    • The Phong Reflection Model
    • Putting It Together
  • Making a Scene
    • Building a World
    • Defining a View Transformation
    • Implementing a Camera
    • Putting It Together
  • Shadows excerpt
    • Lighting in Shadows
    • Testing for Shadows
    • Rendering Shadows
    • Putting It Together
  • Planes
    • Refactoring Shapes
    • Implementing a Plane
    • Putting It Together
  • Patterns
    • Making a Striped Pattern
    • Transforming Patterns
    • Generalizing Patterns
    • Making a Gradient Pattern
    • Making a Ring Pattern
    • Making a 3D Checker Pattern
    • Putting It Together
  • Reflection and Refraction
    • Reflection
    • Transparency and Refraction
    • Fresnel Effect
    • Putting It Together
  • Cubes
    • Intersecting a Ray with a Cube
    • Finding the Normal on a Cube
    • Putting It Together
  • Cylinders
    • Intersecting a Ray with a Cylinder
    • Finding the Normal on a Cylinder
    • Truncating Cylinders
    • Capped Cylinders
    • Cones
    • Putting It Together
  • Groups
    • Implementing Groups
    • Finding the Normal on a Child Object
    • Using Bounding Boxes to Optimize Large Scenes
    • Putting It Together
  • Triangles
    • Triangles
    • Wavefront OBJ Files
    • Smooth Triangles
    • Smooth Triangles in OBJ Files
    • Putting It Together
  • Constructive Solid Geometry (CSG)
    • Implementing CSG
    • Coloring CSG Shapes
    • Putting It Together
  • Next Steps
    • Area Lights and Soft Shadows
    • Spotlights
    • Focal Blur
    • Motion Blur
    • Anti-aliasing
    • Texture Maps
    • Normal Perturbation
    • Torus Primitive
    • Wrapping It Up
  • Rendering the Cover Image

Author

Jamis Buck has been active in open source for years, and has a deep passion for learning. He loves programming puzzles and trying new things, and especially enjoys finding ways to make programming fun again.