dbf-udg

annotate 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
rev   line source
nuclear@7 1 varying vec3 normal, vpos;
nuclear@7 2
nuclear@7 3 void main()
nuclear@7 4 {
nuclear@7 5 vec3 n = normalize(normal);
nuclear@7 6 vec3 v = -normalize(vpos);
nuclear@7 7 vec3 l = normalize(gl_LightSource[0].position.xyz);
nuclear@7 8
nuclear@7 9 vec3 h = normalize(v + l);
nuclear@7 10
nuclear@7 11 float ndotl = max(dot(n, l), 0.0);
nuclear@7 12 float ndoth = max(dot(n, h), 0.0);
nuclear@7 13 float spec = pow(ndoth, gl_FrontMaterial.shininess);
nuclear@7 14
nuclear@7 15 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
nuclear@7 16 vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[0].diffuse.xyz;
nuclear@7 17 vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[0].specular.xyz;
nuclear@7 18
nuclear@7 19 gl_FragColor.xyz = acol + dcol * ndotl + scol * spec;
nuclear@7 20 gl_FragColor.w = 1.0;
nuclear@7 21 }