Skip to content

Commit

Permalink
Add check for backwards-facing rays in RealisticCamera
Browse files Browse the repository at this point in the history
Fixes issue mmp#92. Many thanks to @takiyu for chasing down the problem and
proposing a solution, and @syoyo for an alternative solution, which I've
incorporated here.
  • Loading branch information
mmp committed Jun 11, 2017
1 parent 4194053 commit 9064986
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/cameras/realistic.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -104,9 +104,13 @@ bool RealisticCamera::TraceLensesFromFilm(const Ray &rCamera, Ray *rOut) const {
Float t;
Normal3f n;
bool isStop = (element.curvatureRadius == 0);
if (isStop)
if (isStop) {
// The refracted ray computed in the previous lens element
// interface may be pointed towards film plane(+z) in some
// extreme situations; in such cases, 't' becomes negative.
if (rLens.d.z >= 0.0) return false;
t = (elementZ - rLens.o.z) / rLens.d.z;
else {
} else {
Float radius = element.curvatureRadius;
Float zCenter = elementZ + element.curvatureRadius;
if (!IntersectSphericalElement(radius, zCenter, rLens, &t, &n))
Expand Down

0 comments on commit 9064986

Please sign in to comment.