Debian Codegraph @

shaders/waldwiesen.frag

raw
1 #version 330
2 in vec3 Normalv;
3 in vec3 nor;
4
5 uniform vec4 Color;
6 uniform vec3 lightPos;
7 uniform float lintrans = 1.0;
8 uniform bool lighting = true;
9
10 out vec4 fragColor;
11
12 vec3 blinnPhongDirectional( vec3 n , vec3 kd) {
13 vec3 ambient = kd * 0.5;//Light.La * Material.Ka;
14 vec3 intensity = vec3(0.8, 0.8, 0.8);
15 vec3 s = normalize(lightPos);// directional light
16 float sDotN = abs(dot(s, n));
17 vec3 diffuse = kd * sDotN;
18 vec3 spec = vec3(0.0);
19 float Shininess = 48.0;
20 if (sDotN > 0.0) {
21 spec = vec3(1,1,1) * pow(max(dot(s,n), 0.0), Shininess);
22 }
23 return ambient + intensity * (diffuse + spec);
24 }
25
26 void main( void ){
27 //fragColor = vec4(Normal.rgb, lintrans);
28 //fragColor = vec4(nor.rgb, lintrans);
29 if (lighting){
30 fragColor = vec4(blinnPhongDirectional(Normalv, Color.rgb), lintrans);
31 }else {
32 fragColor = vec4(Color.rgb, lintrans);
33 }
34 }