tesspot

view sdr/bezier.p.glsl @ 0:72b7f9f2eead

initial commit
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 02 Dec 2012 08:23:51 +0200
parents
children 178a9e3c3c8c
line source
1 #version 410 compatibility
3 in vec3 normal;
4 in vec3 vpos;
6 void main()
7 {
8 vec3 ldir = gl_LightSource[0].position.xyz - vpos;
10 vec3 n = normalize(normal);
11 vec3 v = -normalize(vpos);
12 vec3 l = normalize(ldir);
13 vec3 h = normalize(l + v);
15 float ndotl = max(dot(n, l), 0.0);
16 float ndoth = max(dot(n, h), 0.0);
18 vec3 kd = gl_FrontMaterial.diffuse.xyz;
19 vec3 ks = gl_FrontMaterial.specular.xyz;
20 float shin = gl_FrontMaterial.shininess;
22 vec3 diffuse = kd * ndotl * gl_LightSource[0].diffuse.xyz;
23 vec3 specular = ks * pow(ndoth, shin) * gl_LightSource[0].specular.xyz;
25 gl_FragColor = vec4(diffuse + specular, gl_FrontMaterial.diffuse.w);
26 }