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

Razor54672
The answer to 3rd Problem of Chapter 5 (Making Choices) of “Practical Programming, Third Edition” seems incorrect in the given answer ke...
New
herminiotorres
Hi @Margaret , On page VII the book tells us the example and snippets will be all using Elixir version 1.11 But on page 3 almost the en...
New
AleksandrKudashkin
On the page xv there is an instruction to run bin/setup from the main folder. I downloaded the source code today (12/03/21) and can’t see...
New
New
jskubick
I’m running Android Studio “Arctic Fox” 2020.3.1 Patch 2, and I’m embarrassed to admit that I only made it to page 8 before running into ...
New
jskubick
I think I might have found a problem involving SwitchCompat, thumbTint, and trackTint. As entered, the SwitchCompat changes color to hol...
New
taguniversalmachine
Hi, I am getting an error I cannot figure out on my test. I have what I think is the exact code from the book, other than I changed “us...
New
jonmac
The allprojects block listed on page 245 produces the following error when syncing gradle: “org.gradle.api.GradleScriptException: A prob...
New
Keton
When running the program in chapter 8, “Implementing Combat”, the printout Health before attack was never printed so I assumed something ...
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
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
AstonJ
Curious to know which languages and frameworks you’re all thinking about learning next :upside_down_face: Perhaps if there’s enough peop...
New
AstonJ
This looks like a stunning keycap set :orange_heart: A LEGENDARY KEYBOARD LIVES ON When you bought an Apple Macintosh computer in the e...
New
AstonJ
In case anyone else is wondering why Ruby 3 doesn’t show when you do asdf list-all ruby :man_facepalming: do this first: asdf plugin-upd...
New
New
Margaret
Hello everyone! This thread is to tell you about what authors from The Pragmatic Bookshelf are writing on Medium.
1122 25120 742
New
rustkas
Intensively researching Erlang books and additional resources on it, I have found that the topic of using Regular Expressions is either c...
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
Author Spotlight Mike Riley @mriley This month, we turn the spotlight on Mike Riley, author of Portable Python Projects. Mike’s book ...
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 ❯