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.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/object.cpp') diff --git a/src/object.cpp b/src/object.cpp index 6c61d07..1449cbb 100644 --- a/src/object.cpp +++ b/src/object.cpp @@ -10,13 +10,15 @@ void Color::clamp() { if (m_z > 1) { m_z = 1; } } -Material::Material(Color color, double defuse) { +Material::Material(Color color, double defuse, double emissive) { m_color = color; m_defuse = defuse; + m_emissive = emissive; } -Color Material::reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out) const { - return Vec3d(m_color) * (out.dot(normal) * m_defuse); +Color Material::reflect(const Vec3d &normal, const Vec3d &in, const Vec3d &out, const Color &incol) const { + return Vec3d(m_color) * m_emissive + + (Vec3d(m_color) * Vec3d(incol)) * (out.dot(normal) * m_defuse); } Sphere::Sphere(const Material &mat, Vec3d center, double radius) : Shape(mat) { -- cgit v1.2.3