zdybak

zdybak

The Ray Tracer Challenge: reflection tests 4 and 5 failing

@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 are line in world.rs starting on lines 349 and 367

I’ve put in some debug statements in shade_hit to see what’s going on-

Blockquote

---- world::tests::reflected_color_of_reflective_material stdout ----
Hit detected shadow:true with surface: Color { red: 0.08000000000000002, green: 0.1, blue: 0.06 }
and reflected: Color { red: 0.0, green: 0.0, blue: 0.0 }
results in : Color { red: 0.08000000000000002, green: 0.1, blue: 0.06 }
Hit detected shadow:true with surface: Color { red: 0.1, green: 0.1, blue: 0.1 }
and reflected: Color { red: 0.04000000000000001, green: 0.05, blue: 0.03 }
results in : Color { red: 0.14, green: 0.15000000000000002, blue: 0.13 }
thread ‘world::tests::reflected_color_of_reflective_material’ panicked at ‘assertion failed: (left == right)
left: Color { red: 0.07, green: 0.07500000000000001, blue: 0.065 },
right: Color { red: 0.19032, green: 0.2379, blue: 0.14274 }’, src\world.rs:345:9
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

---- world::tests::shade_hit_with_reflective_material stdout ----
Hit detected shadow:true with surface: Color { red: 0.08000000000000002, green: 0.1, blue: 0.06 }
and reflected: Color { red: 0.0, green: 0.0, blue: 0.0 }
results in : Color { red: 0.08000000000000002, green: 0.1, blue: 0.06 }
Hit detected shadow:true with surface: Color { red: 0.1, green: 0.1, blue: 0.1 }
and reflected: Color { red: 0.04000000000000001, green: 0.05, blue: 0.03 }
results in : Color { red: 0.14, green: 0.15000000000000002, blue: 0.13 }
Hit detected shadow:true with surface: Color { red: 0.1, green: 0.1, blue: 0.1 }
and reflected: Color { red: 0.07, green: 0.07500000000000001, blue: 0.065 }
results in : Color { red: 0.17, green: 0.17500000000000002, blue: 0.165 }
thread ‘world::tests::shade_hit_with_reflective_material’ panicked at ‘assertion failed: (left == right)
left: Color { red: 0.17, green: 0.17500000000000002, blue: 0.165 },
right: Color { red: 0.87677, green: 0.92436, blue: 0.82918 }’, src\world.rs:363:9

Blockquote

It looks to me like the green of the default world sphere is instantly only getting ambient because it’s coming up as in shadow, but if the ray is cast down and bouncing up to the bottom of the sphere then I think that’s correct anyway?

Neither of my calculated colors (left side) are even close though.

Marked As Solved

zdybak

zdybak

The issue turned out to be my implementation of planes was not applying local translations to the ray, and basically the plane transform was being ignored. (It became quite clear after rendering the image and seeing the plane bisect the sphere).

More details are listed in the old book forum - Chapter 11 Test #4 and #5 | The Ray Tracer Challenge

Where Next?

Popular Pragmatic Bookshelf topics Top

abtin
page 20: … protoc command… I had to additionally run the following go get commands in order to be able to compile protobuf code using go...
New
brianokken
Many tasks_proj/tests directories exist in chapters 2, 3, 5 that have tests that use the custom markers smoke and get, which are not decl...
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
yulkin
your book suggests to use Image.toByteData() to convert image to bytes, however I get the following error: "the getter ‘toByteData’ isn’t...
New
HarryDeveloper
Hi @venkats, It has been mentioned in the description of ‘Supervisory Job’ title that 2 things as mentioned below result in the same eff...
New
cro
I am working on the “Your Turn” for chapter one and building out the restart button talked about on page 27. It recommends looking into ...
New
Charles
In general, the book isn’t yet updated for Phoenix version 1.6. On page 18 of the book, the authors indicate that an auto generated of ro...
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
AufHe
I’m a newbie to Rails 7 and have hit an issue with the bin/Dev script mentioned on pages 112-113. Iteration A1 - Seeing the list of prod...
New
dachristenson
@mfazio23 Android Studio will not accept anything I do when trying to use the Transformations class, as described on pp. 140-141. Googl...
New

Other popular topics Top

AstonJ
Or looking forward to? :nerd_face:
New
Exadra37
I am thinking in building or buy a desktop computer for programing, both professionally and on my free time, and my choice of OS is Linux...
New
PragmaticBookshelf
Design and develop sophisticated 2D games that are as much fun to make as they are to play. From particle effects and pathfinding to soci...
New
AstonJ
I’ve been hearing quite a lot of comments relating to the sound of a keyboard, with one of the most desirable of these called ‘thock’, he...
New
AstonJ
Just done a fresh install of macOS Big Sur and on installing Erlang I am getting: asdf install erlang 23.1.2 Configure failed. checking ...
New
Exadra37
I am asking for any distro that only has the bare-bones to be able to get a shell in the server and then just install the packages as we ...
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
AstonJ
We’ve talked about his book briefly here but it is quickly becoming obsolete - so he’s decided to create a series of 7 podcasts, the firs...
New
PragmaticBookshelf
Rails 7 completely redefines what it means to produce fantastic user experiences and provides a way to achieve all the benefits of single...
New
PragmaticBookshelf
Author Spotlight: Karl Stolley @karlstolley Logic! Rhetoric! Prag! Wow, what a combination. In this spotlight, we sit down with Karl ...
New

Sub Categories: