Vec3f
EyeLightShader::Shade(Ray& ray)
{
- // shade according to cos(theta)
- Vec3f r = ray.direction();
- Vec3f n = ray.hit()->GetNormal(ray);
- float cos_theta = fabs(r.dot(n) / (r.norm() * n.norm()));
- return m_color * cos_theta;
+ Vec3f N = ray.hit()->GetNormal(ray);
+ float cos_phi = fabs(ray.direction().dot(N));
+
+ return m_color * cos_phi;
}