From 57c2f9241543a7d18eab98077530730d49ee10c2 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 14 Jan 2021 00:56:57 +0100 Subject: Replace color with pbr-book inspired Spectrum class --- src/object.hpp | 26 +++++--------------------- 1 file changed, 5 insertions(+), 21 deletions(-) (limited to 'src/object.hpp') diff --git a/src/object.hpp b/src/object.hpp index 1cfb254..1cfd10d 100644 --- a/src/object.hpp +++ b/src/object.hpp @@ -4,39 +4,23 @@ #include #include "core/vector.hpp" #include "core/ray.hpp" - -class Color : public Vec3d { - public: - Color() {} - Color(const Vec3d &v) : Vec3d(v) {} - Color(double r, double g, double b) : Vec3d(r, g, b) {} - - uint8_t r() { return m_x * 255; } - uint8_t g() { return m_y * 255; } - uint8_t b() { return m_z * 255; } - - Color& operator+=(const Color& op) { - Vec3d::operator+=(op); - return *this; - } - void clamp(); -}; +#include "core/spectrum.hpp" // Implements phong BRDF class Material { public: - Material(Color color, double defuse, double spectral=0, double spectral_pow=0, double emissive=0); + Material(Spectrum color, double defuse, double spectral=0, double spectral_pow=0, double emissive=0); - Color reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out, const Color &incol) const; + Spectrum reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out, const Spectrum &incol) const; - Color emits() const { + Spectrum emits() const { return m_color * m_emissive; } // Whether the material is reflective bool reflects() const { return m_defuse+m_spectral > 0; } private: - Color m_color; + Spectrum m_color; double m_defuse; double m_emissive; double m_spectral; -- cgit v1.2.3