1 #include "ReflectiveEyeLightShader.hxx"
2 #include "Primitive.hxx"
5 ReflectiveEyeLightShader::ReflectiveEyeLightShader(Scene
* scene
,
8 : EyeLightShader(scene
,color
),
9 m_reflectivity(reflectivity
)
13 ReflectiveEyeLightShader::~ReflectiveEyeLightShader()
17 ReflectiveEyeLightShader::ReflectiveEyeLightShader()
24 ReflectiveEyeLightShader::Shade(Ray
& ray
)
26 Vec3f N
= ray
.hit()->GetNormal(ray
);
29 Vec3f color
= EyeLightShader::Shade(ray
);
32 if(ray
.recursionDepth() < RecursionDepth
)
34 // generate reflected ray
35 // ray origin = hitpoint
36 Vec3f origin
= ray
.origin() + ray
.direction()*ray
.t();
37 Vec3f dir
= ray
.direction()-N
*2*N
.dot(ray
.direction());
41 Ray
reflection_ray(origin
, dir
, ray
.recursionDepth()+1);
42 reflection_ray
.setT(Infinity
);
44 // trace reflection ray
45 Vec3f reflected_color
= m_scene
->RayTrace(reflection_ray
);
46 color
+= reflected_color
* m_reflectivity
;
This page took 0.041499 seconds and 5 git commands to generate.