The Ray Tracer Challenge (Pragmatic Bookshelf)

PragmaticBookshelf
Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! In just a couple of weeks, build a ray tracer that renders beautiful scenes with shadows, reflections, 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 forward. Use whichever language and environment you prefer, and do it entirely test-first, so you know it’s correct.

Jamis Buck @jamis

edited by Brian P. Hogan @bphogan

Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! In just a couple of weeks, build a ray tracer that renders beautiful scenes with shadows, reflections, 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 forward. Use whichever language and environment you prefer, and do it entirely test-first, so you know it’s correct.

There’s no research necessary; all the necessary formulas and algorithms are presented and illustrated. Dive into intriguing topics from vectors and matrices; to the algorithms that simulate the intersection of light rays with spheres, planes, cubes, cylinders, and triangles. Lighting and shading effects, such as shadows and reflections, make your scenes come to life, and constructive solid geometry enables you to combine your graphics primitives in simple ways to produce complex shapes.

Play and experiment as you discover the fun of writing a ray tracer. Accept the challenge today!


“Jamis Buck tames a difficult topic using an entertaining, practical approach that even the mathematically averse will enjoy. The test-driven 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.”

–Jason Pike, Director, Software Engineering, Atlas RFID Solutions


  • Full details: Search
  • View this book’s portal and details on how to post errata and suggestions here.

Don’t forget you can get 35% off with your Devtalk discount! Just use the coupon code “devtalk.com" at checkout :+1:

Latest Threads About This Book Top

Shadoka
Hello @jamis and everyone, I’ve implemented the gradient pattern as described in the book and it gives me this output: The code for ...
New
zdybak
@jamis I’m getting odd values for my color calculations in tests 4 and 5 in the reflection section- github.com/zdybak/ray The tests ar...
New
robcat2075
Title: Ray Trace Challenge: Inversion pg 49 I have gotten all my code (including my matrix multiplication and inversion routines) to pas...
New
sraaphorst
@jamis Please use the following format for the title of this thread (then simply delete/replace this text with the content for the threa...
New
simianarmy
@jamis At the end of Chapter 14 the book briefly mentions that materials applied to groups have no effect on children shapes. I’d like ...
New
pdarnowsky
@jamis After introducing the ideas of tuples, vectors, and points, the book goes on to say: But looking at (4, -4, 3) and (-4, 4, -3) ...
New
BrendanLeber
@jamis I’ve been handling 2x2, 3x3, and 4x4 matrices just fine. In fact my code handles NxM matrices right now but I’ve noticed all of ...
New
doja
Hi, I’m stuck on the test for #7 “Intersecting the caps of a closed cylinder”. Tests 3 & 5 are failing as the intersections count i...
New
hgkjshegfskef
@jamis Unfortunately, my final image of chapter 7 is flipped: All the tests from the chapter pass. My camera and ray generation are...
New
jiricodes
Hi @jamis, I’m not sure if this has been discussed elsewhere, so apologies for a potential duplicate. I refer to cone normal calculatio...
New

Most Active This Week Top

Shadoka
Hello @jamis and everyone, I’ve implemented the gradient pattern as described in the book and it gives me this output: The code for ...
New

Most Active This Month Top

Most Active This Year Top

lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
Henrai
Hi, I’m working on the Chapter 8 of the book. After I add add the point_offset, I’m still able to see acne: In the image above, I re...
New
pdarnowsky
@jamis After introducing the ideas of tuples, vectors, and points, the book goes on to say: But looking at (4, -4, 3) and (-4, 4, -3) ...
New

Most Active Last Three Years Top

PragmaticBookshelf
Author Spotlight Jamis Buck @jamis This month, we have the pleasure of spotlighting author Jamis Buck, who has written Mazes for Prog...
New
hgkjshegfskef
The test is as follows: Scenario: Intersecting a scaled sphere with a ray Given r ← ray(point(0, 0, -5), vector(0, 0, 1)) And s ← sphere...
New
jiricodes
Hi @jamis, I’m not sure if this has been discussed elsewhere, so apologies for a potential duplicate. I refer to cone normal calculatio...
New
hgkjshegfskef
@jamis Unfortunately, my final image of chapter 7 is flipped: All the tests from the chapter pass. My camera and ray generation are...
New
BrendanLeber
@jamis I’ve been handling 2x2, 3x3, and 4x4 matrices just fine. In fact my code handles NxM matrices right now but I’ve noticed all of ...
New
robcat2075
Title: Ray Trace Challenge: Inversion pg 49 I have gotten all my code (including my matrix multiplication and inversion routines) to pas...
New
doja
Hi, I’m stuck on the test for #7 “Intersecting the caps of a closed cylinder”. Tests 3 & 5 are failing as the intersections count i...
New
zdybak
@jamis I’m getting odd values for my color calculations in tests 4 and 5 in the reflection section- github.com/zdybak/ray The tests ar...
New
simianarmy
@jamis At the end of Chapter 14 the book briefly mentions that materials applied to groups have no effect on children shapes. I’d like ...
New
sraaphorst
@jamis Please use the following format for the title of this thread (then simply delete/replace this text with the content for the threa...
New

Most Active Over Three Years Top

New
PragmaticBookshelf
Brace yourself for a fun challenge: build a photorealistic 3D renderer from scratch! In just a couple of weeks, build a ray tracer that r...
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
New
kuroneko
Whilst the author has been careful to provide exact results for the tests elsewhere in the book (such as surds with the transformation te...
New
mwomick
The Ray Tracer Challenge by @jamis: p. 28 It appears to me that on page 28, there is an error. The first column of the features/matrices...
New
emmagordon
Feels like a slightly redundant question at this point (since I can already see a lot of similar repos on GitHub), but just to check - is...
New
64kramsystem
In the last hint (#4) of Chapter 5, the pseudocode applies a normalization to the origin ray: r ← ray(ray_origin, normalize(position - ...
New
CraigTreptow
Hi. I’m working on this test: Scenario ​: The pixel size for a horizontal canvas Given ​ c ← camera(200, 125, π/2) Then ​ c.pixel_siz...
New
New
CraigTreptow
Also posted to the old forums. Hello there! I just finished chapter 8, and I now have shadows! Yay! However, when I ran the whole test...
New
FPChris
@jamis Page 130 I render the wall ok by rotating the plane in x PI/2 as he says to do on page 125. However I get a massive shadow acros...
New
64kramsystem
In the book, at the bottom right, there are the “discuss” and “report erratum” links, pointing to: discuss: http://forums.pragprog.com/...
New
FPChris
On Page 37. How to calculate the cofactor for a 4x4 matrix is never shown. Only the 3x3. How is the author getting the cofactor(A,0,0) =...
New
toukov
Hi & thanks for the book! I’m following the book building a ray tracer and would like to publish the code it as open source. I’m usi...
New
jdunlap
I am working on Chapter 8 when we add shadows. When this is done, though (on p. 115), the original ShadeHit test no longer passes. This p...
New

Get money off!

The Pragmatic Bookshelf

35% off any eBook

Simply use coupon code "devtalk.com" at checkout. See full details here.