aboutsummaryrefslogtreecommitdiff
path: root/src/object.cpp
diff options
context:
space:
mode:
authorJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
committerJulian T <julian@jtle.dk>2020-08-13 20:06:29 +0200
commit5b0b916c561f602723b9ae80f5462a7939b652a1 (patch)
tree6ee419f0dd1649b2c329585551f06a555a631db8 /src/object.cpp
parent690b72664ca8d471f5c117f6ed87aeae2de0a208 (diff)
Pathtracing working with defuse and emissive lighting
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) {