// 3x3 Convolution Matrix // v0.1 Theodor Groeneboom // theo@euqahuba.com #define KERNEL_SIZE 9 float vectorLength = float(0.0); const float kernel[KERNEL_SIZE] = {$v1$, $v2$,$v3$,$v4$, $v5$, $v6$,$v7$, $v8$, $v9$}; const float step_w =1.0/input0_tex_width+$val$; const float step_h =1.0/input0_tex_height+$val$; const vec2 offset[KERNEL_SIZE] ={vec2(-step_w, step_h), vec2(0.0, step_h), vec2(step_w, step_h),vec2(-step_w, 0.0), vec2(0.0, 0.0), vec2(step_w, 0.0),vec2(-step_w, -step_h), vec2(0.0, -step_h), vec2(step_w,-step_h)}; int i = 1; vec4 sum = vec4(0.0); vec4 tmp =texture2DRect(input0_tex, input0_v_tex+ offset[0]); sum += tmp *kernel[0]; for(int i=1; i < KERNEL_SIZE; i++) { tmp =texture2DRect(input0_tex, input0_v_tex + offset[i]); sum += tmp* kernel[i]; } vectorLength =($v1$+$v2$+$v3$+$v4$+$v5$+$v6$+$v7$+$v8$+$v9$); if ($norm$ == 1) { sum = sum/vectorLength; } OUT = sum;