mmp / pbrt-v3

Source code for pbrt, the renderer described in the third edition of "Physically Based Rendering: From Theory To Implementation", by Matt Pharr, Wenzel Jakob, and Greg Humphreys.
http://pbrt.org
BSD 2-Clause "Simplified" License
4.89k stars 1.19k forks source link

What happens in `BVHAccel::Intersect` when the ray has one component == 0.0 ? #322

Closed germolinal closed 2 years ago

germolinal commented 2 years ago

So, I was wondering about this line... what happens when the vector has an element == 0? Then one of this values is infinite. Any suggested handling? is it necessary?

https://github.com/mmp/pbrt-v3/blob/aaa552a4b9cbf9dccb71450f47b268e0ed6370e2/src/accelerators/bvh.cpp#L666

mmp commented 2 years ago

Everything just works; IEEE floating point has both positive and negative 'infinite' values that are well-defined; they do sensible things like positive infinity is greater than any finite float in a comparison, etc. There's some further discussion of infinities with ray-bounds intersection tests here.