hit_sphere return value #954
-
The hit_sphere functions returns (-b - sqrt(discriminate))/ (2a). Is there any reason as to why we are returning the difference between -b and the sqrt(discriminate) versus the addition of -b and the sqrt(discriminate) since quadratic functions can have 2 roots. I tested the difference in my code and the one adding those two values together produced a sphere with much vibrant colors. Is this a personal design decision? Or is there a mathematical reason for this choice?
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
At that point in the code, the scene and camera are pretty much hard-coded. All objects are in front of the camera. Given this, the nearest root is guaranteed to be the one with the smallest ray t value. Also, note the comment:
Also note the latter comment:
|
Beta Was this translation helpful? Give feedback.
At that point in the code, the scene and camera are pretty much hard-coded. All objects are in front of the camera. Given this, the nearest root is guaranteed to be the one with the smallest ray t value. Also, note the comment:
Also note the latter comment: