tavli

annotate 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
rev   line source
nuclear@15 1 /* vi: set ft=glsl */
nuclear@15 2 varying vec3 vdir, ldir, normal;
nuclear@15 3
nuclear@15 4 #define KD gl_FrontMaterial.diffuse.rgb
nuclear@15 5 #define KS gl_FrontMaterial.specular.rgb
nuclear@15 6 #define SPOW gl_FrontMaterial.shininess
nuclear@15 7
nuclear@15 8 void main()
nuclear@15 9 {
nuclear@15 10 vec3 n = normalize(normal);
nuclear@15 11 vec3 v = normalize(vdir);
nuclear@15 12 vec3 l = normalize(ldir);
nuclear@15 13 vec3 h = normalize(l + v);
nuclear@15 14
nuclear@15 15 float ndotl = max(dot(n, l), 0.0);
nuclear@15 16 float ndoth = max(dot(n, h), 0.0);
nuclear@15 17
nuclear@15 18 vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl;
nuclear@15 19 vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW);
nuclear@15 20
nuclear@15 21 vec3 ambient = gl_LightModel.ambient.rgb * KD;
nuclear@15 22 gl_FragColor.rgb = ambient + diffuse + specular;
nuclear@15 23 gl_FragColor.a = gl_FrontMaterial.diffuse.a;
nuclear@15 24 }