From dcea04516e545ac55c41df419f1b3be94ac3af80 Mon Sep 17 00:00:00 2001 From: yumcyawiz Date: Mon, 22 Nov 2021 17:19:55 +0900 Subject: [PATCH] allow continue tracing after hitting light in path tracing --- include/integrator.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/include/integrator.h b/include/integrator.h index 406463e..6740e07 100644 --- a/include/integrator.h +++ b/include/integrator.h @@ -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); @@ -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 @@ -68,7 +69,7 @@ class PathTracing : public Integrator { } } - return Vec3f(0); + return radiance; } };