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

Popular Pragmatic Bookshelf topics Top

jimmykiang
This test is broken right out of the box… — FAIL: TestAgent (7.82s) agent_test.go:77: Error Trace: agent_test.go:77 agent_test.go:...
New
New
jon
Some minor things in the paper edition that says “3 2020” on the title page verso, not mentioned in the book’s errata online: p. 186 But...
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
mikecargal
Title: Hands-On Rust (Chap 8 (Adding a Heads Up Display) It looks like ​.with_simple_console_no_bg​(SCREEN_WIDTH*2, SCREEN_HEIGHT*2...
New
brunogirin
When installing Cards as an editable package, I get the following error: ERROR: File “setup.py” not found. Directory cannot be installe...
New
New
adamwoolhether
Is there any place where we can discuss the solutions to some of the exercises? I can figure most of them out, but am having trouble with...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
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

Other popular topics Top

AstonJ
A thread that every forum needs! Simply post a link to a track on YouTube (or SoundCloud or Vimeo amongst others!) on a separate line an...
New
malloryerik
Any thoughts on Svelte? Svelte is a radical new approach to building user interfaces. Whereas traditional frameworks like React and Vue...
New
brentjanderson
Bought the Moonlander mechanical keyboard. Cherry Brown MX switches. Arms and wrists have been hurting enough that it’s time I did someth...
New
AstonJ
I have seen the keycaps I want - they are due for a group-buy this week but won’t be delivered until October next year!!! :rofl: The Ser...
New
mafinar
Crystal recently reached version 1. I had been following it for awhile but never got to really learn it. Most languages I picked up out o...
New
AstonJ
Saw this on TikTok of all places! :lol: Anyone heard of them before? Lite:
New
First poster: bot
The overengineered Solution to my Pigeon Problem. TL;DR: I built a wifi-equipped water gun to shoot the pigeons on my balcony, controlle...
New
PragmaticBookshelf
Author Spotlight: Peter Ullrich @PJUllrich Data is at the core of every business, but it is useless if nobody can access and analyze ...
New
AnfaengerAlex
Hello, I’m a beginner in Android development and I’m facing an issue with my project setup. In my build.gradle.kts file, I have the foll...
New
AstonJ
Curious what kind of results others are getting, I think actually prefer the 7B model to the 32B model, not only is it faster but the qua...
New