dungeon_crawler

view 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 source
1 uniform sampler2D mrt0, mrt1, mrt2, mrt3;
2 uniform vec2 tex_scale, fb_size;
4 uniform vec3 light_color;
5 uniform float light_radius;
7 varying vec3 ltpos;
9 void main()
10 {
11 vec2 tc = gl_FragCoord.xy * tex_scale / fb_size;
13 vec3 pos = texture2D(mrt0, tc).xyz;
14 vec3 norm = texture2D(mrt1, tc).xyz;
16 vec4 texel3 = texture2D(mrt2, tc);
17 vec3 dcol = texel3.xyz;
18 float shin = texel3.w;
20 vec3 ldir = ltpos - pos;
21 float light_dist = length(ldir);
22 ldir = normalize(ldir);
24 float ndotl = dot(norm, ldir);
25 vec3 color = dcol * ndotl;
27 float atten = 1.0 - light_dist / light_radius;
28 atten = clamp(atten, 0.0, 1.0);
30 gl_FragColor = vec4(color * light_color * atten, 1.0);
31 }