%ffp // // 12/04/99 Fixed tile buffer padding bug. // Category:"FM Tutorial" Title: "Box Blur 2" Author: "Ilyich the Toad; Alex Hunter" ctl(0):"V Blur (pixels)",val=1,range=(0,10) ctl(1):"H Blur (pixels)",val=1,range=(0,10) ForEveryTile:{ // Compute rounded, scaled blur radius. int vBlurRadius = (2*ctl(0)+scaleFactor)/(2*scaleFactor); //Vertical blur radius int hBlurRadius = (2*ctl(1)+scaleFactor)/(2*scaleFactor); //Horizontal blur radius // If unscaled radius was nonzero, force scaled radius // to be nonzero also, to show some effect in preview. if (vBlurRadius == 0 && ctl(0) > 0) vBlurRadius = 1; if (hBlurRadius == 0 && ctl(1) > 0) hBlurRadius = 1; { int vWeight = vBlurRadius*2 + 1; int hWeight = hBlurRadius*2 + 1; int count = 0; int counter = 10; int total = (x_end-x_start) + (y_end-y_start); int x, y, z; int i,high,low,val,high1,low1; for (x=x_start-hBlurRadius; x < x_end+hBlurRadius; x++) { if (updateProgress(x-x_start, total)) break; // vertical blur... for (z=0; z < Z; z++) { int sum = 0; for (i=-vBlurRadius; i <= vBlurRadius; i++) { sum += src(x, y_start-1+i, z); } for (y=y_start; y < y_end; y++) { sum += src(x, y+vBlurRadius, z) - src(x, y-vBlurRadius-1, z); val = sum/vWeight; //if (count < counter){ Info("%d",val);count = count + 1;}; high = val>>8; low = val<<24; low = low>>24; val = high<<8; val = val + low; //if (count < counter){ Info("%d",val);count = count + 1;}; tset(x,y,z,high); t2set(x,y,z,low); } } } for (y=y_start; y < y_end; y++) { if (updateProgress(y-y_start + (x_end-x_start), total)) break; // horizontal blur... for (z=0; z < Z; z++) { int sum = 0; for (i=-hBlurRadius; i <= hBlurRadius; i++) { high = tget(x_start-1+i, y, z)<<8; low = t2get(x_start-1+i, y, z); sum += high+low; } for (x=x_start; x < x_end; x++) { low = t2get(x+hBlurRadius, y, z); high = tget(x+hBlurRadius, y, z)<<8; low1 = t2get(x-hBlurRadius-1, y, z); high1 = tget(x-hBlurRadius-1, y, z)<<8; sum += high + low - (high1 + low1); val = sum/hWeight; //if (count < counter){ Info("%d",val);count = count + 1;}; pset(x,y,z,val); } } } } updateProgress(0,0); return true; //Done! }