Debian Codegraph @

shaders/voro.frag

raw
1 #version 330
2
3 in vec3 Normal;
4 in vec4 color;
5 in float distfrommit;
6
7 uniform vec3 lightPos=vec3(1,1,1);
8
9 layout( location = 0 ) out vec4 fragColor;
10
11
12 vec3 blinnPhongDirectional( vec3 n , vec3 kd) {
13 vec3 ambient = kd.xyz*0.5;//Light.La * Material.Ka;
14 vec3 intensity = vec3(0.8, 0.8, 0.8);//specular and diffuse
15 vec3 s = normalize(lightPos);// directional light
16 float sDotN = dot(s,n);
17 float abssDotN = abs(sDotN);
18 vec3 diffuse = kd * abssDotN;
19 vec3 spec = vec3( 0.0, 0.0, 0.0);
20 float Shininess = 48.0;
21 if ((sDotN > 0.1)) {
22 spec = vec3(1,1,1) * pow(sDotN, Shininess);
23 }
24 return ambient + intensity * (diffuse + spec);
25 }
26
27 void main(void){
28 int st = 10;
29 float drawit = fract(distfrommit * st);
30 if (drawit>0.5) discard;
31 if (gl_FrontFacing) fragColor = vec4(blinnPhongDirectional(Normal, color.rgb),1); //vec4(1,0,0,1);
32 else fragColor = vec4(blinnPhongDirectional(-Normal, color.rgb),color.a*0.5);//,vec4(0,1,0,1),0.5);
33 }