diff options
author | Keuin <[email protected]> | 2022-04-14 20:51:27 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-14 20:51:27 +0800 |
commit | ab29b428bdaa9f5a4691c9896b0fcaa9d7368225 (patch) | |
tree | b112231f9afcb8ae51559a1f15d5bcaa0fcd18e0 /hitlist.h | |
parent | ed66f6748c8121aacf6c3cd48b9ac001c85c0978 (diff) |
Move decay accumulation to ray3<T>.
Diffstat (limited to 'hitlist.h')
-rw-r--r-- | hitlist.h | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -44,7 +44,7 @@ public: // Given a ray, compute the color. pixel<T> 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 |