| 1 |
#version 330 |
| 2 |
in vec3 Normal; |
| 3 |
in float col; |
| 4 |
|
| 5 |
uniform vec4 Color[18]; |
| 6 |
uniform vec3 lightPos; |
| 7 |
|
| 8 |
out vec4 fragColor; |
| 9 |
|
| 10 |
vec3 blinnPhongDirectional( vec3 n , vec3 kd) { |
| 11 |
vec3 ambient = kd * 0.5;//Light.La * Material.Ka; |
| 12 |
vec3 intensity = vec3(0.8, 0.8, 0.8); |
| 13 |
vec3 s = normalize(lightPos);// directional light |
| 14 |
float sDotN = abs(dot(s, n)); |
| 15 |
vec3 diffuse = kd * sDotN; |
| 16 |
vec3 spec = vec3(0.0); |
| 17 |
float Shininess = 48.0; |
| 18 |
if (sDotN > 0.0) { |
| 19 |
spec = vec3(1,1,1) * pow(max(dot(s,n), 0.0), Shininess); |
| 20 |
} |
| 21 |
return ambient + intensity * (diffuse + spec); |
| 22 |
} |
| 23 |
|
| 24 |
void main( void ){ |
| 25 |
int coli = int(col+0.5); |
| 26 |
//fragColor = vec4(Color[coli].rgb,1); |
| 27 |
fragColor = vec4(blinnPhongDirectional( Normal, Color[coli].rgb), Color[coli].a); |
| 28 |
} |