-
I was doing fine following the instructions and codes of the book 1, but one problem occurred when I began the dielectric chapter. PS: Sorry for my bad English BTW |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 7 replies
-
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 correct, you could debug your code by sending just a single ray towards the sphere and examining things under a debugger. Hope this helps! |
Beta Was this translation helpful? Give feedback.
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…