jdunlap

jdunlap

The Ray Tracer Challenge: Implementing Shading Breaks the First Shading Test on P. 95

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 point is in shadow and will, therefore, break the tests once shading is implemented.

My solution was to add a flag to turn shading on and off. It defaults to on, but I turn it off before running this test so that it runs as originally intended. I then turn it back on for the final test that is added on p. 114.

For anyone who wants to just update the test, here is the value that I get:

Expected: {0.38066, 0.47583, 0.2855, 0 }
Actual: {0.08, 0.1, 0.06, 0 }

The Actual would just be the ambient color of the sphere.

The second test from p. 95 also fails. Those values are:

Expected: {0.90498, 0.90498, 0.90498, 0 }
Actual: {0.1, 0.1, 0.1, 0 }

Edit:

Shading also breaks the Render test on p. 104 and the second colorAt test on p. 96.

These tests need to be changed to test for the Ambient color or shading needs to be turned off to run them.

It would be nice if Jamis would create tests for all of these that are not in shade or would adjust these tests in the text since the design of the program changed.

First Post!

jamis

jamis

Author of Mazes for Programmers and 1 other title

Hello,

The tests as written should be passing; my own renderer passes all tests, through the end of the book. Admittedly, there could very well be an error in my own code that permits this, but other readers have also had these tests pass after the shadow chapter.

Is your code hosted anywhere that I can see it? I’d be happy to take a look.

  • Jamis

Where Next?

Popular Pragmatic Bookshelf topics Top

telemachus
Python Testing With Pytest - Chapter 2, warnings for “unregistered custom marks” While running the smoke tests in Chapter 2, I get these...
New
ianwillie
Hello Brian, I have some problems with running the code in your book. I like the style of the book very much and I have learnt a lot as...
New
jesse050717
Title: Web Development with Clojure, Third Edition, pg 116 Hi - I just started chapter 5 and I am stuck on page 116 while trying to star...
New
brian-m-ops
#book-python-testing-with-pytest-second-edition Hi. Thanks for writing the book. I am just learning so this might just of been an issue ...
New
AndyDavis3416
@noelrappin Running the webpack dev server, I receive the following warning: ERROR in tsconfig.json TS18003: No inputs were found in c...
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
jwandekoken
Book: Programming Phoenix LiveView, page 142 (157/378), file lib/pento_web/live/product_live/form_component.ex, in the function below: d...
New
bjnord
Hello @herbert ! Trying to get the very first “Hello, Bracket Terminal!" example to run (p. 53). I develop on an Amazon EC2 instance runn...
New
dachristenson
I just bought this book to learn about Android development, and I’m already running into a major issue in Ch. 1, p. 20: “Update activity...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

ohm
Which, if any, games do you play? On what platform? I just bought (and completed) Minecraft Dungeons for my Nintendo Switch. Other than ...
New
PragmaticBookshelf
A PragProg Hero’s Journey with Brian P. Hogan @bphogan Have you ever worried that your only legacy will be in the form of legacy...
New
siddhant3030
I’m thinking of buying a monitor that I can rotate to use as a vertical monitor? Also, I want to know if someone is using it for program...
New
New
Exadra37
On modern versions of macOS, you simply can’t power on your computer, launch a text editor or eBook reader, and write or read, without a ...
New
AstonJ
Seems like a lot of people caught it - just wondered whether any of you did? As far as I know I didn’t, but it wouldn’t surprise me if I...
New
New
AstonJ
If you want a quick and easy way to block any website on your Mac using Little Snitch simply… File > New Rule: And select Deny, O...
New
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New
PragmaticBookshelf
Author Spotlight: Sophie DeBenedetto @SophieDeBenedetto The days of the traditional request-response web application are long gone, b...
New

Sub Categories: