still broken reflective eyelight shader, solution for assignment 2.2b
authorRoland Hieber <rhieber@gaffel.ibr.cs.tu-bs.de>
Wed, 20 Jan 2010 11:30:51 +0000 (12:30 +0100)
committerRoland Hieber <rhieber@gaffel.ibr.cs.tu-bs.de>
Wed, 20 Jan 2010 11:30:51 +0000 (12:30 +0100)
Ray.cxx
ReflectiveEyeLightShader.cxx

diff --git a/Ray.cxx b/Ray.cxx
index 86b1294..a3c76cb 100644 (file)
--- a/Ray.cxx
+++ b/Ray.cxx
@@ -5,7 +5,8 @@
 Ray::Ray()
   : m_org(Vec3f()),
     m_dir(Vec3f()),
-    m_hit(0)
+    m_hit(0),
+    m_level(10)
 {
   m_t = std::numeric_limits<float>::max();
 }
@@ -14,7 +15,8 @@ Ray::Ray(const Vec3f& org,
         const Vec3f& dir)
   : m_org(org),
     m_dir(dir),
-    m_hit(0)
+    m_hit(0),
+    m_level(10)
 {
   m_t = std::numeric_limits<float>::max();
 }
@@ -29,6 +31,7 @@ Ray::Ray(const Ray& r)
   m_dir = r.m_dir;
   m_t = r.m_t;
   m_hit = r.m_hit;
+  m_level = r.m_level;
 }
 
 Ray&
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.026799 seconds and 4 git commands to generate.