diff options
Diffstat (limited to 'src/object.hpp')
-rw-r--r-- | src/object.hpp | 17 |
1 files changed, 14 insertions, 3 deletions
diff --git a/src/object.hpp b/src/object.hpp index 2957acb..e697ba2 100644 --- a/src/object.hpp +++ b/src/object.hpp @@ -15,19 +15,30 @@ class Color : public Vec3d { 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(); - }; // Implements phong BRDF class Material { public: - Material(Color color, double defuse); + Material(Color color, double defuse, double emissive=0); + + Color reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out, const Color &incol) const; + + Color emits() const { + return m_color * m_emissive; + } - Color reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out) const; + // Whether the material is reflective + bool reflects() const { return m_defuse > 0; } private: Color m_color; double m_defuse; + double m_emissive; }; class Shape { |