Commit 90649865 authored by Matt Pharr's avatar Matt Pharr

Add check for backwards-facing rays in RealisticCamera

Fixes issue #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.
parent 41940536
......@@ -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))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment