From 23efb01b4d55c9e0918d67589c97cf1dee31bb9a Mon Sep 17 00:00:00 2001 From: johannes hanika Date: Mon, 3 Nov 2014 17:31:38 +0100 Subject: [PATCH] hslt: always use a consistent edge direction in the bidirectional abstraction layer --- include/mitsuba/bidir/edge.h | 2 ++ src/libbidir/edge.cpp | 15 ++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/include/mitsuba/bidir/edge.h b/include/mitsuba/bidir/edge.h index 648a6975..17bc8599 100644 --- a/include/mitsuba/bidir/edge.h +++ b/include/mitsuba/bidir/edge.h @@ -53,6 +53,8 @@ struct MTS_EXPORT_BIDIR PathEdge { /** * \brief Normalized direction vector associated with this edge + * + * The direction always points along the light path (from the light) */ Vector d; diff --git a/src/libbidir/edge.cpp b/src/libbidir/edge.cpp index e4fec2c3..3c9cc2d5 100644 --- a/src/libbidir/edge.cpp +++ b/src/libbidir/edge.cpp @@ -63,6 +63,9 @@ bool PathEdge::sampleNext(const Scene *scene, Sampler *sampler, weight[1-mode] = mRec.transmittance / pdf[1-mode]; } d = ray.d; + /* Direction always points along the light path (from the light source along the path) */ + if(mode == ERadiance) + d = -d; return true; } @@ -105,6 +108,9 @@ bool PathEdge::perturbDirection(const Scene *scene, return false; } d = ray.d; + /* Direction always points along the light path (from the light source along the path) */ + if(mode == ERadiance) + d = -d; if (length == 0) return false; @@ -274,6 +280,9 @@ bool PathEdge::connect(const Scene *scene, } } + /* Direction always points along the light path (from the light source along the path) */ + d = -d; + return true; } @@ -330,7 +339,8 @@ bool PathEdge::pathConnect(const Scene *scene, const PathEdge *predEdge, result.append(edge); edge->length = std::min(its.t, remaining); edge->medium = medium; - edge->d = d; + /* Direction always points along the light path (from the light source along the path) */ + edge->d = -d; if (medium) { MediumSamplingRecord mRec; @@ -557,6 +567,9 @@ bool PathEdge::pathConnectAndCollapse(const Scene *scene, const PathEdge *predEd } } + /* Direction always points along the light path (from the light source along the path) */ + d = -d; + return true; }