Skip to content

Problems with dielectrics in One Weekend #997

Answered by ghadeeras
a42027756 asked this question in Q&A
Discussion options

You must be logged in to vote

Hello!

My guess is that you might have a problem in the way you calculate the normal when the ray hits the sphere surface from the inside (that is, after it had refracted for the first time and scattered inside the sphere)

I see in your sphere class, you have two main cases to examine the two intersection points between the ray and the sphere. In one of them, you are not using the normal's setter method, which I believe adjusts the direction of the normal depending on whether the ray hits the surface from the outside or the inside.

Long story short, I think your rays are bouncing infinitely inside the dielectric sphere after they have refracted the first time. If my guess above is not cor…

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@a42027756
Comment options

@NoodleLadJr
Comment options

@lyzirving
Comment options

@quadpixels
Comment options

@9mm
Comment options

Answer selected by a42027756
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
6 participants