tavli
diff sdr/phong-notex.p.glsl @ 15:b1a195c3ee16
added shaders
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sun, 28 Jun 2015 08:34:24 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sdr/phong-notex.p.glsl Sun Jun 28 08:34:24 2015 +0300 1.3 @@ -0,0 +1,24 @@ 1.4 +/* vi: set ft=glsl */ 1.5 +varying vec3 vdir, ldir, normal; 1.6 + 1.7 +#define KD gl_FrontMaterial.diffuse.rgb 1.8 +#define KS gl_FrontMaterial.specular.rgb 1.9 +#define SPOW gl_FrontMaterial.shininess 1.10 + 1.11 +void main() 1.12 +{ 1.13 + vec3 n = normalize(normal); 1.14 + vec3 v = normalize(vdir); 1.15 + vec3 l = normalize(ldir); 1.16 + vec3 h = normalize(l + v); 1.17 + 1.18 + float ndotl = max(dot(n, l), 0.0); 1.19 + float ndoth = max(dot(n, h), 0.0); 1.20 + 1.21 + vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl; 1.22 + vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW); 1.23 + 1.24 + vec3 ambient = gl_LightModel.ambient.rgb * KD; 1.25 + gl_FragColor.rgb = ambient + diffuse + specular; 1.26 + gl_FragColor.a = gl_FrontMaterial.diffuse.a; 1.27 +}