dbf-udg

diff 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 diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/sdr/phong.p.glsl	Mon Feb 18 05:44:17 2013 +0200
     1.3 @@ -0,0 +1,21 @@
     1.4 +varying vec3 normal, vpos;
     1.5 +
     1.6 +void main()
     1.7 +{
     1.8 +	vec3 n = normalize(normal);
     1.9 +	vec3 v = -normalize(vpos);
    1.10 +	vec3 l = normalize(gl_LightSource[0].position.xyz);
    1.11 +
    1.12 +	vec3 h = normalize(v + l);
    1.13 +
    1.14 +	float ndotl = max(dot(n, l), 0.0);
    1.15 +	float ndoth = max(dot(n, h), 0.0);
    1.16 +	float spec = pow(ndoth, gl_FrontMaterial.shininess);
    1.17 +
    1.18 +	vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
    1.19 +	vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[0].diffuse.xyz;
    1.20 +	vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[0].specular.xyz;
    1.21 +
    1.22 +	gl_FragColor.xyz = acol + dcol * ndotl + scol * spec;
    1.23 +	gl_FragColor.w = 1.0;
    1.24 +}