8eae6109f08f12e638aa7ee2875ff3617fc67659
[MicroTrace.git] / EyeLightShader.cxx
1 #include "EyeLightShader.hxx"
2 #include "Primitive.hxx"
3
4 EyeLightShader::EyeLightShader(Scene* scene,
5 const Vec3f& color)
6 : Shader(scene),
7 m_color(color)
8 {
9 }
10
11 EyeLightShader::~EyeLightShader()
12 {
13 }
14
15 EyeLightShader::EyeLightShader()
16 : Shader(0),
17 m_color(Vec3f())
18 {
19 }
20
21 Vec3f
22 EyeLightShader::Shade(Ray& ray)
23 {
24 // shade according to cos(theta)
25 Vec3f r = ray.direction();
26 Vec3f n = ray.hit()->GetNormal(ray);
27 float cos_theta = fabs(r.dot(n) / (r.norm() * n.norm()));
28 return m_color * cos_theta;
29 }
This page took 0.040492 seconds and 3 git commands to generate.