intravenous

diff 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 diff
     1.1 --- a/sdr/vein.p.glsl	Sun Apr 22 05:20:03 2012 +0300
     1.2 +++ b/sdr/vein.p.glsl	Sun Apr 22 06:26:08 2012 +0300
     1.3 @@ -1,8 +1,13 @@
     1.4  uniform sampler2D tex_norm;
     1.5 +uniform vec3 fog_col;
     1.6  
     1.7  varying vec3 vpos, vnorm;
     1.8  varying vec3 ldir, vdir;
     1.9  
    1.10 +const float fog_dens = 0.075;
    1.11 +
    1.12 +float fog(float dist);
    1.13 +
    1.14  void main()
    1.15  {
    1.16  	vec3 tnorm = texture2D(tex_norm, gl_TexCoord[0].st).xyz * 2.0 - 1.0;
    1.17 @@ -14,5 +19,13 @@
    1.18  	vec3 diff = vec3(0.8, 0.25, 0.2) * (1.0 - max(dot(l, n), 0.0));
    1.19  	vec3 spec = 0.5 * vec3(0.9, 0.4, 0.3) * pow(max(dot(h, n), 0.0), 10.0);
    1.20  
    1.21 -	gl_FragColor = vec4(diff + spec, 1.0);
    1.22 +	vec3 color = mix(fog_col, diff + spec, fog(vpos.z));
    1.23 +
    1.24 +	gl_FragColor = vec4(color, 1.0);
    1.25  }
    1.26 +
    1.27 +#define LOG2E	1.442695
    1.28 +float fog(float dist)
    1.29 +{
    1.30 +	return clamp(exp2(-fog_dens * fog_dens * dist * dist * LOG2E), 0.0, 1.0);
    1.31 +}