From 5b0b916c561f602723b9ae80f5462a7939b652a1 Mon Sep 17 00:00:00 2001 From: Julian T Date: Thu, 13 Aug 2020 20:06:29 +0200 Subject: Pathtracing working with defuse and emissive lighting --- src/object.hpp | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) (limited to 'src/object.hpp') 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 { -- cgit v1.2.3