Skip to content

Commit

Permalink
Minor update.
Browse files Browse the repository at this point in the history
  • Loading branch information
tatsy committed Jul 25, 2018
1 parent 0b48ac3 commit ac53a3c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 13 deletions.
1 change: 1 addition & 0 deletions sources/core/film.cc
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ void Film::save(int id, double scale) const {
void Film::setImage(const Image& image) {
this->image_ = image;
weights_.assign(resolution_.x(), std::vector<double>(resolution_.y(), 1.0));
samples_.assign(resolution_.x(), std::vector<int>(resolution_.y(), 1));
}

void Film::addPixel(const Point2i& pixel, const Point2d& pInPixel,
Expand Down
22 changes: 9 additions & 13 deletions sources/integrators/gdpt/gdpt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ struct Vertex {
SurfaceEventRecord surfaceRecord;
};

bool nextDirection(const SurfaceInteraction &isect, const Vertex &prev, const Vertex &current, const Vertex &next,
bool nextDirection(const Scene &scene, const SurfaceInteraction &isect, const Vertex &prev, const Vertex &current, const Vertex &next,
Vector3d *wiOffset, double *pdf, Spectrum *f, double *J, bool *reconnect, bool *specularBounce) {
const Vector3d woOffset = isect.wo();
*reconnect = false;
Expand Down Expand Up @@ -199,7 +199,9 @@ bool nextDirection(const SurfaceInteraction &isect, const Vertex &prev, const Ve
*wiOffset = vect::normalize(next.pos() - isect.pos());
*f = isect.bsdf()->f(woOffset, *wiOffset);
*pdf = isect.bsdf()->pdf(woOffset, *wiOffset);
*reconnect = true;

VisibilityTester tester(isect, Interaction(next.pos(), next.normal()));
*reconnect = tester.unoccluded(scene);
} else if ((current.isDiffuse() && isect.bsdf()->hasType(BxDFType::Diffuse)) ||
(current.isGlossy() && isect.bsdf()->hasType(BxDFType::Glossy))) {
// Half-vector copy
Expand Down Expand Up @@ -318,22 +320,15 @@ TraceRecord shiftMap(const Scene &scene, RenderParams &params, const Ray &r, Sam
return TraceRecord(PathType::NotInvertible);
}

// If previous and current vertices are reconnected,
// confirm whether next base and offset vertices are the same.
if (reconnect) {
if ((isect.pos() - current.pos()).norm() > 1.0e-6) {
// Occlusion occur
return TraceRecord(PathType::NonSymmetric);
}
reconnect = false;
}

// Check light endpoint
if (specularBounce || bounces == 1) {
Spectrum Le(0.0);
if (isIntersect) {
// Area light
Le = isect.Le(-ray.dir());
if (!Le.isBlack() && bounces == 1) {
return TraceRecord(PathType::NotInvertible);
}
} else {
// Not area light (e.g. envmap)
for (const auto &light : scene.lights()) {
Expand Down Expand Up @@ -381,7 +376,8 @@ TraceRecord shiftMap(const Scene &scene, RenderParams &params, const Ray &r, Sam
double J = 1.0, pdf = 0.0;
Spectrum f(0.0);
specularBounce = false;
bool foundNext = nextDirection(isect, prev, current, next, &wiSub, &pdf, &f, &J, &reconnect, &specularBounce);
reconnect = false;
bool foundNext = nextDirection(scene, isect, prev, current, next, &wiSub, &pdf, &f, &J, &reconnect, &specularBounce);
if (!foundNext || f.isBlack() || pdf == 0.0 || J == 0.0) {
return TraceRecord(PathType::NotInvertible);
}
Expand Down

0 comments on commit ac53a3c

Please sign in to comment.