tavli
diff 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 diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sdr/shadow-notex.p.glsl Mon Jun 29 01:29:36 2015 +0300 1.3 @@ -0,0 +1,29 @@ 1.4 +/* vi: set ft=glsl */ 1.5 +uniform sampler2DShadow shadowmap; 1.6 + 1.7 +varying vec3 vdir, ldir, normal; 1.8 +varying vec4 shadow_tc; 1.9 + 1.10 +#define KD gl_FrontMaterial.diffuse.rgb 1.11 +#define KS gl_FrontMaterial.specular.rgb 1.12 +#define SPOW gl_FrontMaterial.shininess 1.13 + 1.14 +void main() 1.15 +{ 1.16 + float shadow = shadow2DProj(shadowmap, shadow_tc).x; 1.17 + 1.18 + vec3 n = normalize(normal); 1.19 + vec3 v = normalize(vdir); 1.20 + vec3 l = normalize(ldir); 1.21 + vec3 h = normalize(l + v); 1.22 + 1.23 + float ndotl = max(dot(n, l), 0.0); 1.24 + float ndoth = max(dot(n, h), 0.0); 1.25 + 1.26 + vec3 diffuse = KD * gl_LightSource[0].diffuse.rgb * ndotl; 1.27 + vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW); 1.28 + 1.29 + vec3 ambient = gl_LightModel.ambient.rgb * KD; 1.30 + gl_FragColor.rgb = ambient + (diffuse + specular) * shadow; 1.31 + gl_FragColor.a = gl_FrontMaterial.diffuse.a; 1.32 +}