equal
deleted
inserted
replaced
57 |
57 |
58 // calculate shader function |
58 // calculate shader function |
59 // P is point of intersection, N normal in this point |
59 // P is point of intersection, N normal in this point |
60 Colour PhongShader_ambient(Material &mat, Vector3 &P) |
60 Colour PhongShader_ambient(Material &mat, Vector3 &P) |
61 { |
61 { |
62 Colour col = mat.texture.colour; //mat.texture.evaluate(P); |
62 Colour col; |
|
63 if (mat.texture) |
|
64 col = mat.texture->evaluate(P); |
|
65 else |
|
66 col = mat.colour; |
63 |
67 |
64 // ambient |
68 // ambient |
65 return mat.ambient * col; |
69 return mat.ambient * col; |
66 } |
70 } |
67 |
71 |
78 Vector3 L = light.pos - P; |
82 Vector3 L = light.pos - P; |
79 L.normalize(); |
83 L.normalize(); |
80 Float L_dot_N = dot(L, N); |
84 Float L_dot_N = dot(L, N); |
81 Float R_dot_V = dot(R, V); |
85 Float R_dot_V = dot(R, V); |
82 |
86 |
83 Colour col = mat.texture.colour; //mat.texture.evaluate(P); |
87 Colour col; |
|
88 if (mat.texture) |
|
89 col = mat.texture->evaluate(P); |
|
90 else |
|
91 col = mat.colour; |
84 |
92 |
85 // diffuse |
93 // diffuse |
86 I = mat.diffuse * col * light.colour * L_dot_N; |
94 I = mat.diffuse * col * light.colour * L_dot_N; |
87 |
95 |
88 // specular |
96 // specular |