From d883ff94342f418b87ac2333b3fdf779bd2dfa0f Mon Sep 17 00:00:00 2001 From: Keuin Date: Wed, 13 Apr 2022 13:34:50 +0800 Subject: Generalize hitlist and basic_viewport. (HDR in the future) --- hitlist.h | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) (limited to 'hitlist.h') diff --git a/hitlist.h b/hitlist.h index 18a8226..0c65e1a 100644 --- a/hitlist.h +++ b/hitlist.h @@ -19,7 +19,8 @@ #include -// A world +// A world, T is color depth +template class hitlist { std::vector> objects; @@ -34,7 +35,7 @@ public: } // Given a ray, compute the color. - pixel8b color(const ray3d &r) const { + pixel color(const ray3d &r) const { // Detect hits bool hit = false; double hit_t = std::numeric_limits::infinity(); @@ -53,15 +54,15 @@ public: const auto nv = hit_obj->normal_vector(r.at(hit_t)); // return obj->color(); // visualize normal vector at hit point - return pixel8b::from_normalized(nv); + return pixel::from_normalized(nv); } // Does not hit anything. Get background color (infinity) const auto u = (r.direction().y + 1.0) * 0.5; return mix( - pixel8b::from_normalized(1.0, 1.0, 1.0), - pixel8b::from_normalized(0.5, 0.7, 1.0), + pixel::from_normalized(1.0, 1.0, 1.0), + pixel::from_normalized(0.5, 0.7, 1.0), 1.0 - u, u ); @@ -70,4 +71,6 @@ public: }; +using hitlist8b = hitlist; + #endif //RT_HITLIST_H -- cgit v1.2.3