still broken reflective eyelight shader, solution for assignment 2.2b
[MicroTrace.git] / ReflectiveEyeLightShader.cxx
index 2bd0db3..e7fa2ac 100644 (file)
@@ -1,4 +1,6 @@
 #include "ReflectiveEyeLightShader.hxx"
+#include "Primitive.hxx"
+#include "Scene.hxx"
 
 ReflectiveEyeLightShader::ReflectiveEyeLightShader(Scene* scene,
                                                   float reflectivity,
@@ -21,5 +23,16 @@ ReflectiveEyeLightShader::ReflectiveEyeLightShader()
 Vec3f
 ReflectiveEyeLightShader::Shade(Ray& ray)
 {
-  return Vec3f();
+  Vec3f eyeColor = EyeLightShader::Shade(ray);
+  Vec3f reflColor;
+
+  // shoot secondary rays from intersection
+  Vec3f n = ray.hit()->GetNormal(ray);
+  Ray sec(ray.origin() + ray.direction() * ray.t(), ray.direction() + n * 2);
+  sec.setRecursionDepth(ray.recursionDepth() - 1);
+
+  if(ray.recursionDepth() > 0 && m_scene->Intersect(sec)) {
+    reflColor = Shade(sec);
+  }
+  return eyeColor + reflColor;
 }
This page took 0.024688 seconds and 4 git commands to generate.