solution to assignment 2.2 b): eyelight shader
authorRoland Hieber <rohieb@rohieb.name>
Wed, 20 Jan 2010 01:34:48 +0000 (02:34 +0100)
committerRoland Hieber <rohieb@rohieb.name>
Wed, 20 Jan 2010 01:34:48 +0000 (02:34 +0100)
EyeLightShader.cxx

index 12578d7..8eae610 100644 (file)
@@ -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;
 }
This page took 0.026215 seconds and 4 git commands to generate.