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.

1 Like