ld33_umonster

view sdr/shadow.p.glsl @ 10:1b30bd381667

sweep curve mesh gen and dragon horns
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 27 Aug 2015 05:25:04 +0300
parents
children
line source
1 /* vi: set ft=glsl */
2 uniform sampler2D tex;
3 uniform sampler2DShadow shadowmap;
5 varying vec3 vdir, ldir, normal;
6 varying vec4 shadow_tc;
8 #define KD gl_FrontMaterial.diffuse.rgb
9 #define KS gl_FrontMaterial.specular.rgb
10 #define SPOW gl_FrontMaterial.shininess
12 void main()
13 {
14 float shadow = shadow2DProj(shadowmap, shadow_tc).x;
15 vec4 texel = texture2D(tex, gl_TexCoord[0].st);
17 vec3 n = normalize(normal);
18 vec3 v = normalize(vdir);
19 vec3 l = normalize(ldir);
20 vec3 h = normalize(l + v);
22 float ndotl = max(dot(n, l), 0.0);
23 float ndoth = max(dot(n, h), 0.0);
25 vec3 albedo = KD * texel.rgb;
26 vec3 diffuse = albedo * gl_LightSource[0].diffuse.rgb * ndotl;
27 vec3 specular = KS * gl_LightSource[0].specular.rgb * pow(ndoth, SPOW);
29 vec3 ambient = gl_LightModel.ambient.rgb * albedo;
30 gl_FragColor.rgb = ambient + (diffuse + specular) * shadow;
31 gl_FragColor.a = gl_FrontMaterial.diffuse.a * texel.a;
32 }