From 3e9d9dd0040fc7b578bb49bac41e8292ce16a685 Mon Sep 17 00:00:00 2001 From: Roland Hieber Date: Wed, 20 Jan 2010 02:34:48 +0100 Subject: [PATCH] solution to assignment 2.2 b): eyelight shader --- EyeLightShader.cxx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) 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; } -- 2.20.1