diff options
author | Julian T <julian@jtle.dk> | 2020-08-13 20:06:29 +0200 |
---|---|---|
committer | Julian T <julian@jtle.dk> | 2020-08-13 20:06:29 +0200 |
commit | 5b0b916c561f602723b9ae80f5462a7939b652a1 (patch) | |
tree | 6ee419f0dd1649b2c329585551f06a555a631db8 /src/object.hpp | |
parent | 690b72664ca8d471f5c117f6ed87aeae2de0a208 (diff) |
Pathtracing working with defuse and emissive lighting
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 { |