intravenous

view sdr/vein.p.glsl @ 5:aab0d8ea21cd

normalmap and sortof subsurface shader
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 22 Apr 2012 06:26:08 +0300
parents c6a6a64df6de
children 2723dc026c4f
line source
1 uniform sampler2D tex_norm;
2 uniform vec3 fog_col;
4 varying vec3 vpos, vnorm;
5 varying vec3 ldir, vdir;
7 const float fog_dens = 0.075;
9 float fog(float dist);
11 void main()
12 {
13 vec3 tnorm = texture2D(tex_norm, gl_TexCoord[0].st).xyz * 2.0 - 1.0;
14 vec3 n = normalize(tnorm);
15 vec3 v = normalize(vdir);
16 vec3 l = v;//normalize(ldir);
17 vec3 h = normalize(l + v);
19 vec3 diff = vec3(0.8, 0.25, 0.2) * (1.0 - max(dot(l, n), 0.0));
20 vec3 spec = 0.5 * vec3(0.9, 0.4, 0.3) * pow(max(dot(h, n), 0.0), 10.0);
22 vec3 color = mix(fog_col, diff + spec, fog(vpos.z));
24 gl_FragColor = vec4(color, 1.0);
25 }
27 #define LOG2E 1.442695
28 float fog(float dist)
29 {
30 return clamp(exp2(-fog_dens * fog_dens * dist * dist * LOG2E), 0.0, 1.0);
31 }