Skip to content

Commit

Permalink
allow continue tracing after hitting light in path tracing
Browse files Browse the repository at this point in the history
  • Loading branch information
yumcyaWiz committed Nov 22, 2021
1 parent 127aa75 commit dcea045
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions include/integrator.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class PathTracing : public Integrator {

Vec3f integrate(const Ray& ray_in, const Scene& scene,
Sampler& sampler) const override {
Vec3f radiance(0);
Ray ray = ray_in;
Vec3f throughput(1, 1, 1);

Expand All @@ -50,8 +51,8 @@ class PathTracing : public Integrator {

// Le
if (info.hitPrimitive->hasAreaLight()) {
return throughput *
info.hitPrimitive->Le(info.surfaceInfo, -ray.direction);
radiance += throughput *
info.hitPrimitive->Le(info.surfaceInfo, -ray.direction);
}

// sample direction by BxDF
Expand All @@ -68,7 +69,7 @@ class PathTracing : public Integrator {
}
}

return Vec3f(0);
return radiance;
}
};

Expand Down

0 comments on commit dcea045

Please sign in to comment.