tavli

view sdr/phong-notex.p.glsl @ 21:c3fbf9616dbd

slot bounds, and ray testing
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 02 Jul 2015 00:01:39 +0300
parents
children
line source
1 /* vi: set ft=glsl */
2 varying vec3 vdir, ldir, normal;
4 #define KD gl_FrontMaterial.diffuse.rgb
5 #define KS gl_FrontMaterial.specular.rgb
6 #define SPOW gl_FrontMaterial.shininess
8 void main()
9 {
10 vec3 n = normalize(normal);
11 vec3 v = normalize(vdir);
12 vec3 l = normalize(ldir);
13 vec3 h = normalize(l + v);
15 float ndotl = max(dot(n, l), 0.0);
16 float ndoth = max(dot(n, h), 0.0);
18 vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl;
19 vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW);
21 vec3 ambient = gl_LightModel.ambient.rgb * KD;
22 gl_FragColor.rgb = ambient + diffuse + specular;
23 gl_FragColor.a = gl_FrontMaterial.diffuse.a;
24 }