From ab29b428bdaa9f5a4691c9896b0fcaa9d7368225 Mon Sep 17 00:00:00 2001 From: Keuin Date: Thu, 14 Apr 2022 20:51:27 +0800 Subject: Move decay accumulation to ray3. --- hitlist.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'hitlist.h') diff --git a/hitlist.h b/hitlist.h index d498b26..02c942a 100644 --- a/hitlist.h +++ b/hitlist.h @@ -44,7 +44,7 @@ public: // Given a ray, compute the color. pixel color(ray3d r, random_uv_gen_3d &ruvg, uint_fast32_t max_recursion_depth = 64) const { - double decay = 1; + assert(r.decay() == 1.0); while (max_recursion_depth-- > 0) { // Detect hits bool hit = false; @@ -90,8 +90,8 @@ public: #ifdef DIFFUSE_HEMI vec3d diffuse_target = hit_point + ruvg.hemisphere(nv); #endif - decay *= 0.5; // lose 50% light when diffused - r = ray3d{hit_point, diffuse_target - hit_point}; // the new diffused ray we trace on + r.decay(0.5); // lose 50% light when diffused + r.source(hit_point); r.direction((diffuse_target - hit_point).unit_vec()); // the new diffused ray we trace on continue; #endif } @@ -105,7 +105,7 @@ public: u ); #ifdef T_DIFFUSE - return decay * c; + return r.hit(c); #else return c; #endif -- cgit v1.2.3