diff options
author | Keuin <[email protected]> | 2022-04-13 13:34:50 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2022-04-13 13:34:50 +0800 |
commit | d883ff94342f418b87ac2333b3fdf779bd2dfa0f (patch) | |
tree | 5ccd2cac2ed714d59eb27d90c7d78e39741aa966 /hitlist.h | |
parent | d1a748cea4c1c33d6979c32181ff4a17da9ecd71 (diff) |
Generalize hitlist and basic_viewport. (HDR in the future)
Diffstat (limited to 'hitlist.h')
-rw-r--r-- | hitlist.h | 13 |
1 files changed, 8 insertions, 5 deletions
@@ -19,7 +19,8 @@ #include <cstdint> -// A world +// A world, T is color depth +template<typename T> class hitlist { std::vector<std::shared_ptr<object>> objects; @@ -34,7 +35,7 @@ public: } // Given a ray, compute the color. - pixel8b color(const ray3d &r) const { + pixel<T> color(const ray3d &r) const { // Detect hits bool hit = false; double hit_t = std::numeric_limits<double>::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<T>::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<T>::from_normalized(1.0, 1.0, 1.0), + pixel<T>::from_normalized(0.5, 0.7, 1.0), 1.0 - u, u ); @@ -70,4 +71,6 @@ public: }; +using hitlist8b = hitlist<uint8_t>; + #endif //RT_HITLIST_H |