tavli
view sdr/shadow-notex.p.glsl @ 18:986c0b76513f
shadows, not completed
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 29 Jun 2015 01:29:36 +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 }