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

Popular Prag Prog topics Top

johnp
Hi Brian, Looks like the api for tinydb has changed a little. Noticed while working on chapter 7 that the .purge() call to the db throws...
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
lirux
Hi Jamis, I think there’s an issue with a test on chapter 6. I own the ebook, version P1.0 Feb. 2019. This test doesn’t pass for me: ...
New
herminiotorres
Hi! I know not the intentions behind this narrative when called, on page XI: mount() |> handle_event() |> render() but the correc...
New
jeremyhuiskamp
Title: Web Development with Clojure, Third Edition, vB17.0 (p9) The create table guestbook syntax suggested doesn’t seem to be accepted ...
New
Chrichton
Dear Sophie. I tried to do the “Authorization” exercise and have two questions: When trying to plug in an email-service, I found the ...
New
swlaschin
The book has the same “Problem space/Solution space” diagram on page 18 as is on page 17. The correct Problem/Solution space diagrams ar...
New
leba0495
Hello! Thanks for the great book. I was attempting the Trie (chap 17) exercises and for number 4 the solution provided for the autocorre...
New
adamwoolhether
When trying to generate the protobuf .go file, I receive this error: Unknown flag: --go_opt libprotoc 3.12.3 MacOS 11.3.1 Googling ...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
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
AstonJ
SpaceVim seems to be gaining in features and popularity and I just wondered how it compares with SpaceMacs in 2020 - anyone have any thou...
New
New
PragmaticBookshelf
Rust is an exciting new programming language combining the power of C with memory safety, fearless concurrency, and productivity boosters...
New
dimitarvp
Small essay with thoughts on macOS vs. Linux: I know @Exadra37 is just waiting around the corner to scream at me “I TOLD YOU SO!!!” but I...
New
Exadra37
Oh just spent so much time on this to discover now that RancherOS is in end of life but Rancher is refusing to mark the Github repo as su...
New
foxtrottwist
A few weeks ago I started using Warp a terminal written in rust. Though in it’s current state of development there are a few caveats (tab...
New
AstonJ
If you get Can't find emacs in your PATH when trying to install Doom Emacs on your Mac you… just… need to install Emacs first! :lol: bre...
New
PragmaticBookshelf
Author Spotlight Rebecca Skinner @RebeccaSkinner Welcome to our latest author spotlight, where we sit down with Rebecca Skinner, auth...
New
PragmaticBookshelf
Author Spotlight: VM Brasseur @vmbrasseur We have a treat for you today! We turn the spotlight onto Open Source as we sit down with V...
New

Latest in PragProg

View all threads ❯