r/GraphicsProgramming • • Aug 07 '24

Raytracing in One Weekend SetFaceNormal Error

Currently working on Raytracing in one weekend and keep running into this issue where my SetFaceNormal() is causing that ring on the sphere. I’ve commented out where the function is called to show that it renders correctly. My set face normal math is 1:1 to the book yet I get the ring? Can anyone explain where I may have gone wrong?

2 Upvotes

5 comments sorted by

2

u/Ok-Sherbert-6569 Aug 07 '24 edited Aug 07 '24

I’ve a feeling you’re intersecting the sphere at front and back side because you’re not culling the furthest intersection point with the ray. Let’s see your intersection function Edit : just checked your intersection function and I’ve no idea why you’re doing what you’re doing. You either intersect with the sphere or you don’t. This range checking in nonsense stuff. Take the smallest t and as long as it’s not negative then you have your valid intersection

-1

u/Public-Slip8450 Aug 07 '24

Can I get line number and file? Also is the entire intersection code nonsense or a specific part if so can I get a snippet?

1

u/Ok-Sherbert-6569 Aug 07 '24

Like 29 in your intersection file. No it’s all good I’m just not sure what you’re doing with this whole interval thing. I’m guessing you’re using that for casss where your ray originates inside the sphere and your smallest t is in fact negative and is the invalid solution?

0

u/Public-Slip8450 Aug 07 '24

I’d have to refer to the book on that one but they implement the class to clean up what was being doing previously it’s in a previous commit of mine.