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
belgoros
Following the steps described in Chapter 6 of the book, I’m stuck with running the migration as described on page 84: bundle exec sequel...
New
jamis
The following is cross-posted from the original Ray Tracer Challenge forum, from a post by garfieldnate. I’m cross-posting it so that the...
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
joepstender
The generated iex result below should list products instead of product for the metadata. (page 67) iex> product = %Product{} %Pento....
New
jskubick
I found an issue in Chapter 7 regarding android:backgroundTint vs app:backgroundTint. How to replicate: load chapter-7 from zipfile i...
New
brunogirin
When running tox for the first time, I got the following error: ERROR: InterpreterNotFound: python3.10 I realised that I was running ...
New
New
gorkaio
root_layout: {PentoWeb.LayoutView, :root}, This results in the following following error: no “root” html template defined for PentoWeb...
New
roadbike
From page 13: On Python 3.7, you can install the libraries with pip by running these commands inside a Python venv using Visual Studio ...
New

Other popular topics Top

Devtalk
Reading something? Working on something? Planning something? Changing jobs even!? If you’re up for sharing, please let us know what you’...
1023 17214 380
New
AstonJ
Or looking forward to? :nerd_face:
New
DevotionGeo
I know that -t flag is used along with -i flag for getting an interactive shell. But I cannot digest what the man page for docker run com...
New
AstonJ
poll poll Be sure to check out @Dusty’s article posted here: An Introduction to Alternative Keyboard Layouts It’s one of the best write-...
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
PragmaticBookshelf
Author Spotlight James Stanier @jstanier James Stanier, author of Effective Remote Work , discusses how to rethink the office as we e...
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
husaindevelop
Inside our android webview app, we are trying to paste the copied content from another app eg (notes) using navigator.clipboard.readtext ...
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
First poster: bot
Large Language Models like ChatGPT say The Darnedest Things. The Errors They MakeWhy We Need to Document Them, and What We Have Decided ...
New

Sub Categories: