dungeon_crawler

diff prototype/sdr/deferred_omni.p.glsl @ 33:0357994effe2

ha! fixed deferred
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 28 Aug 2012 03:18:47 +0300
parents 938a6a155c94
children 85734f319626
line diff
     1.1 --- a/prototype/sdr/deferred_omni.p.glsl	Tue Aug 28 02:18:19 2012 +0300
     1.2 +++ b/prototype/sdr/deferred_omni.p.glsl	Tue Aug 28 03:18:47 2012 +0300
     1.3 @@ -1,6 +1,9 @@
     1.4  uniform sampler2D mrt0, mrt1, mrt2, mrt3;
     1.5  uniform vec2 tex_scale, fb_size;
     1.6  
     1.7 +uniform vec3 light_color;
     1.8 +uniform float light_radius;
     1.9 +
    1.10  varying vec3 ltpos;
    1.11  
    1.12  void main()
    1.13 @@ -15,16 +18,14 @@
    1.14  	float shin = texel3.w;
    1.15  
    1.16  	vec3 ldir = ltpos - pos;
    1.17 -	float dist = length(ldir);
    1.18 +	float light_dist = length(ldir);
    1.19  	ldir = normalize(ldir);
    1.20  
    1.21  	float ndotl = dot(norm, ldir);
    1.22  	vec3 color = dcol * ndotl;
    1.23  
    1.24 -	float atten = 1.0;
    1.25 -	if(dist > 0.2) {
    1.26 -		atten = 0.0;
    1.27 -	}
    1.28 +	float atten = 1.0 - light_dist / light_radius;
    1.29 +	atten = clamp(atten, 0.0, 1.0);
    1.30  
    1.31 -	gl_FragColor = vec4(color, 1.0);
    1.32 +	gl_FragColor = vec4(color * light_color * atten, 1.0);
    1.33  }