Is there a way to make the script faster? Duplicates of 50 takes forever for a convolution of 100 px. PDN plugin Splinter Blur version is a lot faster, but that may has to do with applied multi-threading, and I can’t find out about that because it’s not open source.
Since I changed variables, here’s the current code.
Splinter Blur
The part I want to make faster is the part close to ang={} line.
#@cli rep_splinter_blur: _length,_duplicates,_angle,_thickness,_sharpen_multiplier,-1<=_balance<=1,_boundary={ 0=None | 1=Neumann | 2=Periodic | 3=Mirror },_bisided={ 0=one-line | two-line }
#@cli : Apply Splinter Blur to Image. Based off observation from using Splinter Blur plugin within Paint.NET made by Ed Harvey. Note that convolution result is different.
rep_splinter_blur:
skip ${1=10%},${2=5},${3=0},${4=0},${5=0},${6=0},${7=1},${8=0}
start_ang={$3}
angs_per_dups={360/$2}
m "average_output: ti=$! add / $ti"
if $6==-1 m "output_splinter : min"
elif $6<0&&$6>-1 m "output_splinter : +average_output +min[^-1] f. lerp(i#-2,i,abs($6)) k."
elif $6==0 m "output_splinter : average_output"
elif $6>0&&$6<1 m "output_splinter : +average_output +max[^-1] f. lerp(i#-2,i,$6) k."
elif $6==1 m "output_splinter : max"
else error (-1<=\$\6<=1)=F
fi
repeat $! l[$>]
cutval={im},{iM}
hypo={(sqrt(w^2+h^2)/2)}
if ${is_percent\ $1} length={round($1*$hypo)}
else length={round($1)}
fi
if ${is_percent\ $4} thickness={round($4*$hypo)}
else thickness={round($4)}
fi
ds={d},{s}
if $7!=2 expand_xy {round($length/2)},$7 fi
repeat $2
ang={$start_ang+$angs_per_dups*$>}
+rep_splinter_blur_convolve_map. $length,$thickness,$ang,$5,$8
+convolve_fft[0] [-1]
rm..
done
rm[0]
output_splinter
cut $cutval
if $7!=2 shrink_xy {round($length/2)} fi
endl done
um average_output,output_splinter,splinter_convolve
#@cli rep_splinter_blur_convolve_map: _length,_thickness,_angle,_sharpen_multiplier,_bisided={ 0=one-line | two-line }
#@cli : Create a convolve map for directional blur. This enables one to create a convolve map for one-direction motion blur.
#@cli : Default values: '_length=10%','_thickness=5%','_angle=0','_bisided=1'
rep_splinter_blur_convolve_map : skip ${1=10%},${2=5%},${3=0},${5=1}
repeat $! l[$>]
hypo={(sqrt(w^2+h^2)/2)}
if ${is_percent\ $1} length={round($1*$hypo)} else length={round($1)} fi
if ${is_percent\ $2} thickness={max(round($2*$hypo),1)} else thickness={max(round($2),1)} fi
ds={d},{s}
rm
{$length},{$length},1,1
f "begin(
const sides=$5;
const thickness="$thickness";
const hw=(w-1)/2;
const hh=(h-1)/2;
const ang=($3/180)*pi*-1;
const cos_ang=cos(ang);
const sin_ang=sin(ang);
rot_x(a,b)=a*cos_ang-b*sin_ang;
rot_y(a,b)=a*sin_ang+b*cos_ang;
cutval(v)=v<0?0:v;
maxcutval(v)=v>1?1:v;
);
xx=x/w-.5;
yy=y/h-.5;
lx=x-hw;
ly=y-hh;
radial_grad=1-sqrt(xx^2+yy^2)*2;
radial_grad=cutval(radial_grad);
line=1-maxcutval(abs(rot_x(lx,ly))/thickness);
sides?(line?radial_grad*line):(rot_y(lx,ly)<=0?(line?radial_grad*line));
"
/ {is}
if $4
avgstat={ia}
+f (i*2-$avgstat)
f.. lerp(i,i#1,min(1,$4))
k[0]
fi
r 100%,100%,$ds,0,1
endl done
Note to self, try to create radial duplicates on the fill block. That might be the solution.
EDIT: Just tested the note to self idea. Nope.