From: Roland Hieber Date: Wed, 20 Jan 2010 01:34:48 +0000 (+0100) Subject: solution to assignment 2.2 b): eyelight shader X-Git-Url: https://git.rohieb.name/MicroTrace.git/commitdiff_plain/3e9d9dd0040fc7b578bb49bac41e8292ce16a685 solution to assignment 2.2 b): eyelight shader --- diff --git a/EyeLightShader.cxx b/EyeLightShader.cxx index 12578d7..8eae610 100644 --- a/EyeLightShader.cxx +++ b/EyeLightShader.cxx @@ -1,4 +1,5 @@ #include "EyeLightShader.hxx" +#include "Primitive.hxx" EyeLightShader::EyeLightShader(Scene* scene, const Vec3f& color) @@ -20,5 +21,9 @@ EyeLightShader::EyeLightShader() Vec3f EyeLightShader::Shade(Ray& ray) { - return Vec3f(); + // 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; }