Phong does not work yet, but saving here
[MicroTrace.git] / PointLight.cxx
index 1ce5f0b..2efe585 100644 (file)
@@ -21,8 +21,16 @@ PointLight::PointLight()
 bool
 PointLight::Illuminate(Ray& ray, Vec3f& intensity)
 {
+  float dist = ((ray.origin() + ray.direction() * ray.t()) - m_pos).norm();
 
-  return false;
+  float c1 = 1, c2 = 0.5, c3 = 0;
+  float f_att = 1 / (c1 + c2*dist + c3*dist*dist);
+
+  intensity = m_intensity * f_att;
+
+  // store direction from light to hitpoint
+  ray.setDir(ray.origin() + ray.direction() * (ray.t()-Epsilon) - m_pos);
+  return true;
 }
 
 const Vec3f&
This page took 0.021436 seconds and 4 git commands to generate.