dbf-udg

view sdr/phong.p.glsl @ 7:603656331514

phong blobs
author John Tsiombikas <nuclear@member.fsf.org>
date Mon, 18 Feb 2013 05:44:17 +0200
parents
children f0a47f46ee45
line source
1 varying vec3 normal, vpos;
3 void main()
4 {
5 vec3 n = normalize(normal);
6 vec3 v = -normalize(vpos);
7 vec3 l = normalize(gl_LightSource[0].position.xyz);
9 vec3 h = normalize(v + l);
11 float ndotl = max(dot(n, l), 0.0);
12 float ndoth = max(dot(n, h), 0.0);
13 float spec = pow(ndoth, gl_FrontMaterial.shininess);
15 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
16 vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[0].diffuse.xyz;
17 vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[0].specular.xyz;
19 gl_FragColor.xyz = acol + dcol * ndotl + scol * spec;
20 gl_FragColor.w = 1.0;
21 }