sdrblurtest

annotate 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
rev   line source
nuclear@0 1 uniform sampler2D tex;
nuclear@0 2 uniform vec2 size, texsize;
nuclear@0 3
nuclear@0 4 #define KSZ 31
nuclear@0 5 #define HALF_KSZ 15
nuclear@0 6 #define SCALE float(KSZ * KSZ)
nuclear@0 7
nuclear@0 8 void main()
nuclear@0 9 {
nuclear@0 10 float pixw = 1.0 / texsize.x;
nuclear@0 11 float pixh = 1.0 / texsize.y;
nuclear@0 12
nuclear@0 13 vec3 texel = vec3(0.0, 0.0, 0.0);
nuclear@0 14 for(int i=0; i<KSZ; i++) {
nuclear@0 15 for(int j=0; j<KSZ; j++) {
nuclear@0 16 float x = float(j - HALF_KSZ) * pixw;
nuclear@0 17 float y = float(i - HALF_KSZ) * pixh;
nuclear@0 18 vec2 uv = gl_TexCoord[0].st + vec2(x, y);
nuclear@0 19 texel += texture2D(tex, uv).rgb;
nuclear@0 20 }
nuclear@0 21 }
nuclear@0 22
nuclear@0 23 gl_FragColor.rgb = texel / SCALE;
nuclear@0 24 gl_FragColor.a = 1.0;
nuclear@0 25 }