dbf-udg

view sdr/phong.p.glsl @ 8:f0a47f46ee45

lalala
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 18 Feb 2013 06:53:44 +0200
parents 603656331514
children 1abbed71e9c9
line source
1 varying vec3 normal, vpos;
3 void main()
4 {
5 vec3 n = normalize(normal);
6 vec3 v = -normalize(vpos);
8 vec3 color = vec3(0.0, 0.0, 0.0);
10 for(int i=0; i<2; i++) {
11 vec3 l = normalize(gl_LightSource[i].position.xyz);
12 vec3 h = normalize(v + l);
14 float ndotl = max(dot(n, l), 0.0);
15 float ndoth = max(dot(n, h), 0.0);
16 float spec = pow(ndoth, gl_FrontMaterial.shininess);
18 vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[i].diffuse.xyz;
19 vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[i].diffuse.xyz;
21 color += dcol * ndotl + scol * spec;
22 }
24 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
26 gl_FragColor.xyz = acol + color;
27 gl_FragColor.w = 1.0;
28 }