Closed dominikh closed 6 years ago
Note that the ray direction isn't normalized; d is set to be p2 - origin. Thus, at t=0, the ray is at origin, and at t=1 it's at p2. (And thus, taking an epsilon off there makes it stop just before p2.
I see! Thanks for the quick response.
I'll leave the issue open in case you want to clarify that piece of code in the next edition. Feel free to close the issue if not :-)
Noted for the 4th edition. :-) Thanks!
The Interaction::SpawnRayTo method sets the shadow ray's max distance to 1 - ShadowEpsilon, "so that they stop before the surface of light sources". Even after hours of looking at this, I fail to see how this works in the general case, where the shaded point and the light source may be an arbitrary distance >= 1 away from each other. All the uses of the returned ray assume that it is in world space and do not transform or otherwise modify tMax. Why shouldn't tMax be set to Distance(origin, p2) - ShadowEpsilon instead?
Clearly the current implementation is correct, else it would render most scenes incorrectly; yet why this works is not evident to me from the source code or the book.
https://github.com/mmp/pbrt-v3/blob/8dbd937584c48a4e82261b8aefbab9141dae9171/src/core/interaction.h#L71