still broken reflective eyelight shader, solution for assignment 2.2b
[MicroTrace.git] / ReflectiveEyeLightShader.cxx
1 #include "ReflectiveEyeLightShader.hxx"
2 #include "Primitive.hxx"
3 #include "Scene.hxx"
4
5 ReflectiveEyeLightShader::ReflectiveEyeLightShader(Scene* scene,
6 float reflectivity,
7 const Vec3f& color)
8 : EyeLightShader(scene,color),
9 m_reflectivity(reflectivity)
10 {
11 }
12
13 ReflectiveEyeLightShader::~ReflectiveEyeLightShader()
14 {
15 }
16
17 ReflectiveEyeLightShader::ReflectiveEyeLightShader()
18 : EyeLightShader(0),
19 m_reflectivity(0)
20 {
21 }
22
23 Vec3f
24 ReflectiveEyeLightShader::Shade(Ray& ray)
25 {
26 Vec3f eyeColor = EyeLightShader::Shade(ray);
27 Vec3f reflColor;
28
29 // shoot secondary rays from intersection
30 Vec3f n = ray.hit()->GetNormal(ray);
31 Ray sec(ray.origin() + ray.direction() * ray.t(), ray.direction() + n * 2);
32 sec.setRecursionDepth(ray.recursionDepth() - 1);
33
34 if(ray.recursionDepth() > 0 && m_scene->Intersect(sec)) {
35 reflColor = Shade(sec);
36 }
37 return eyeColor + reflColor;
38 }
This page took 0.055995 seconds and 5 git commands to generate.