The Ray Tracer Challenge
A Test-Driven Guide to Your First 3D Renderer
by Jamis Buck
Version: P1.0 (February 2019)
Copyright 2019 The Pragmatic Programmers, LLC. This book is licensed to the individual who purchased it. We don't copy-protect it because that would limit your ability to use it for your own purposes. Please don't break this trustyou can use this across all of your devices but please do not share this copy with other members of your team, with friends, or via file sharing services. Thanks.
Many of the designations used by manufacturers and sellers to distinguish their products are claimed as trademarks. Where those designations appear in this book, and The Pragmatic Programmers, LLC was aware of a trademark claim, the designations have been printed in initial capital letters or in all capitals. The Pragmatic Starter Kit, The Pragmatic Programmer, Pragmatic Programming, Pragmatic Bookshelf and the linking g device are trademarks of The Pragmatic Programmers, LLC.
Every precaution was taken in the preparation of this book. However, the publisher assumes no responsibility for errors or omissions, or for damages that may result from the use of information (including program listings) contained herein.
About the Pragmatic Bookshelf
The Pragmatic Bookshelf is an agile publishing company. Were here because we want to improve the lives of developers. We do this by creating timely, practical titles, written by programmers for programmers.
Our Pragmatic courses, workshops, and other products can help you and your team create better software and have more fun. For more information, as well as the latest Pragmatic titles, please visit us at http://pragprog.com.
Our ebooks do not contain any Digital Restrictions Management, and have always been DRM-free. We pioneered the beta book concept, where you can purchase and read a book while its still being written, and provide feedback to the author to help make a better book for everyone. Free resources for all purchasers include source code downloads (if applicable), errata and discussion forums, all available on the book's home page at pragprog.com. Were here to make your life easier.
New Book Announcements
Want to keep up on our latest titles and announcements, and occasional special offers? Just create an account on pragprog.com (an email address and a password is all it takes) and select the checkbox to receive newsletters. You can also follow us on twitter as @pragprog.
About Ebook Formats
If you buy directly from pragprog.com, you get ebooks in all available formats for one price. You can synch your ebooks amongst all your devices (including iPhone/iPad, Android, laptops, etc.) via Dropbox. You get free updates for the life of the edition. And, of course, you can always come back and re-download your books when needed. Ebooks bought from the Amazon Kindle store are subject to Amazon's polices. Limitations in Amazon's file format may cause ebooks to display differently on different devices. For more information, please see our FAQ at pragprog.com/frequently-asked-questions/ebooks. To learn more about this book and access the free resources, go to https://pragprog.com/book/jbtracer, the book's homepage.
Thanks for your continued support,
Andy Hunt
The Pragmatic Programmers
The team that produced this book includes: Andy Hunt (Publisher) Janet Furlow (VP of Operations) Susan Conant (Managing Editor) Brian P. Hogan (Development Editor) L. Sakhi MacMillan (Copy Editor) Potomac Indexing, LLC (Indexing) Gilson Graphics (Layout)
For customer support, please contact .
For international rights, please contact .
Table of Contents
Copyright 2019, The Pragmatic Bookshelf.
Early Praise for The Ray Tracer Challenge
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 Ive always wanted to get into but have struggled to find anything approachable for someone who doesnt know or isnt 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, youll create an incredibly sophisticated ray tracing library. Because each change is so small, your ray tracer will sneak up on you. Thats the devious part: by the end youll 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 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.
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, youll 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 its now fun! The Ray Tracer Challenge gave me back my joy for pet projects. I recommend it to everyone!
Gbor Lszl Hajba |
Senior IT Consultant |
One of the tricks to avoiding programmer burnout is to find a passion project. In this book, youll find exactly that: an awesome personal project that you can tackle regardless of your language background. Jamiss The Ray Tracer Challenge shows us that the best passion projects are shared.
Kevin Gisi |
Senior UX Engineer |
Acknowledgments
This book exists because my son wanted to learn how to write software. Id tinkered with ray tracers years ago, hacking on POV-Ray and writing my own simple renderers, so when he asked for my help, my first thought was to walk him through writing one of his own. From that experiment was born an idea, which became an outline, which became a book proposal, which became this book.