aboutsummaryrefslogtreecommitdiff
path: root/src/object.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/object.cpp')
-rw-r--r--src/object.cpp8
1 files changed, 5 insertions, 3 deletions
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) {