tavli

view sdr/shadow-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 uniform sampler2DShadow shadowmap;
4 varying vec3 vdir, ldir, normal;
5 varying vec4 shadow_tc;
7 #define KD gl_FrontMaterial.diffuse.rgb
8 #define KS gl_FrontMaterial.specular.rgb
9 #define SPOW gl_FrontMaterial.shininess
11 void main()
12 {
13 float shadow = shadow2DProj(shadowmap, shadow_tc).x;
15 vec3 n = normalize(normal);
16 vec3 v = normalize(vdir);
17 vec3 l = normalize(ldir);
18 vec3 h = normalize(l + v);
20 float ndotl = max(dot(n, l), 0.0);
21 float ndoth = max(dot(n, h), 0.0);
23 vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl;
24 vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW);
26 vec3 ambient = gl_LightModel.ambient.rgb * KD;
27 gl_FragColor.rgb = ambient + (diffuse + specular) * shadow;
28 gl_FragColor.a = gl_FrontMaterial.diffuse.a;
29 }