dbf-udg

annotate 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
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
nuclear@8 8 vec3 color = vec3(0.0, 0.0, 0.0);
nuclear@7 9
nuclear@8 10 for(int i=0; i<2; i++) {
nuclear@8 11 vec3 l = normalize(gl_LightSource[i].position.xyz);
nuclear@8 12 vec3 h = normalize(v + l);
nuclear@8 13
nuclear@8 14 float ndotl = max(dot(n, l), 0.0);
nuclear@8 15 float ndoth = max(dot(n, h), 0.0);
nuclear@8 16 float spec = pow(ndoth, gl_FrontMaterial.shininess);
nuclear@8 17
nuclear@8 18 vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[i].diffuse.xyz;
nuclear@8 19 vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[i].diffuse.xyz;
nuclear@8 20
nuclear@8 21 color += dcol * ndotl + scol * spec;
nuclear@8 22 }
nuclear@7 23
nuclear@7 24 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
nuclear@7 25
nuclear@8 26 gl_FragColor.xyz = acol + color;
nuclear@7 27 gl_FragColor.w = 1.0;
nuclear@7 28 }