Skip to content

Can somebody help me with the refraction bug? #1641

Closed Answered by whydoubt
Bowen951209 asked this question in Q&A
Discussion options

You must be logged in to vote

Note that an eta value of 1.0 should allow a ray to enter the sphere, and exit, without altering the direction of the ray, making the sphere effectively invisible. If you test this with your code, there are still problems. So you are correct that the refract is not the problem.

I found two places that seem to be making this not behave properly:

  • In near_zero() you need to checking against abs() of each component. That is causing the bit of blue sphere visible in the lower half but not the upper.
  • In get_color(), you only continue/recurse if dot(ray.dir, hit_record.normal) > 0.0. Inside the if (has_hit_anything) block, I believe you should always continue/recurse.

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by Bowen951209
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants