sdrblurtest
diff sdr/blur.glsl @ 0:26513fdda566
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Thu, 17 Oct 2013 08:19:56 +0300 |
parents | |
children |
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/sdr/blur.glsl Thu Oct 17 08:19:56 2013 +0300 1.3 @@ -0,0 +1,25 @@ 1.4 +uniform sampler2D tex; 1.5 +uniform vec2 size, texsize; 1.6 + 1.7 +#define KSZ 31 1.8 +#define HALF_KSZ 15 1.9 +#define SCALE float(KSZ * KSZ) 1.10 + 1.11 +void main() 1.12 +{ 1.13 + float pixw = 1.0 / texsize.x; 1.14 + float pixh = 1.0 / texsize.y; 1.15 + 1.16 + vec3 texel = vec3(0.0, 0.0, 0.0); 1.17 + for(int i=0; i<KSZ; i++) { 1.18 + for(int j=0; j<KSZ; j++) { 1.19 + float x = float(j - HALF_KSZ) * pixw; 1.20 + float y = float(i - HALF_KSZ) * pixh; 1.21 + vec2 uv = gl_TexCoord[0].st + vec2(x, y); 1.22 + texel += texture2D(tex, uv).rgb; 1.23 + } 1.24 + } 1.25 + 1.26 + gl_FragColor.rgb = texel / SCALE; 1.27 + gl_FragColor.a = 1.0; 1.28 +}