X-Git-Url: https://git.rohieb.name/MicroTrace.git/blobdiff_plain/49b259147e3ece2ed0aa4ad72b686970031cfc46..9fa235f6c621a9737be66359dc6bed473f1823d9:/PointLight.cxx?ds=sidebyside diff --git a/PointLight.cxx b/PointLight.cxx index 1ce5f0b..2efe585 100644 --- a/PointLight.cxx +++ b/PointLight.cxx @@ -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&