-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEyeLightTextureShader.hh
50 lines (39 loc) · 1.13 KB
/
EyeLightTextureShader.hh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#ifndef EYALIGHTTEXTURESHADER_HH
#define EYALIGHTTEXTURESHADER_HH
#include "Basic.hh"
#include "Texture.hh"
class EyeLightTextureShader : public Shader
{
public:
Vec3f color;
char * file_texture;
Texture *texture;
EyeLightTextureShader();
EyeLightTextureShader(Vec3f color,char* filename)
: color(color), file_texture(filename)
{
texture = new Texture();
//cout << file_texture << endl;
cout << texture->LoadPPM(file_texture) << endl;
//cout << "============>" << texture->GetTexel(10,10).z << endl;
};
~EyeLightTextureShader()
{};
//eyeLightshader
virtual Vec3f Shade(Ray &ray)
{
color = color;//* fabs(Dot(ray.dir,ray.hit->GetNormal(ray)));
float u, v;
ray.hit->GetUV(ray, u, v);
Vec3f textureColor = texture->GetTexel(u, v) ;
//cout << textureColor.x << "," << textureColor.y << "," << textureColor.z << endl;
//cout << "[" << color.x << "," << color.y << "," << color.z << "]" << endl;
Vec3f result = Product(color, textureColor) ;
result.assertInterval(0,1);
return result* fabs(Dot(ray.dir,ray.hit->GetNormal(ray))); ;
};
virtual Vec3f getColor(){
return color;
};
};
#endif