code for assignment 4, gitignored *.ppm, *.png
[MicroTrace.git] / ReflectiveEyeLightShader.cxx
index 0adb174..59f9444 100644 (file)
@@ -24,11 +24,14 @@ Vec3f
 ReflectiveEyeLightShader::Shade(Ray& ray)
 {
   Vec3f N = ray.hit()->GetNormal(ray);
+  // turn normal to front
+  if(N.dot(ray.direction()) > 0)
+    N *= -1;
   
-  // diffuse color
-  Vec3f color = EyeLightShader::Shade(ray); 
+  float cos_phi = fabs(ray.direction().dot(N));
+
+  Vec3f color = m_color * cos_phi;
  
-  // add reflection
   if(ray.recursionDepth() < RecursionDepth)
     {
       // generate reflected ray
This page took 0.020575 seconds and 4 git commands to generate.