ld33_umonster
view sdr/shadow-notex.p.glsl @ 7:92d662deb66e
capsule distance seems broken
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Tue, 25 Aug 2015 00:38:00 +0300 |
parents | 35349df5392d |
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;
14 shadow = min(shadow + 1.0 - step(0.0, shadow_tc.w), 1.0);
16 vec3 n = normalize(normal);
17 vec3 v = normalize(vdir);
18 vec3 l = normalize(ldir);
19 vec3 h = normalize(l + v);
21 float ndotl = max(dot(n, l), 0.0);
22 float ndoth = max(dot(n, h), 0.0);
24 vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl;
25 vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW);
27 vec3 ambient = gl_LightModel.ambient.rgb * KD;
28 gl_FragColor.rgb = ambient + (diffuse + specular) * shadow;
29 gl_FragColor.a = gl_FrontMaterial.diffuse.a;
30 }