filter "Custom Diffusion"; group "TMTS Stylize"; input apply, "Mode", Popup, 1, "Normal", "Add", "Subtract", "Difference", "Multiply", "Screen", "Overlay", "Darken", "Lighten"; input ts, "Threshold", slider, 128, 0, 255 input tl, "Tolerance", slider, 100, 0, 100 input ab, "Mask Feather", slider, 25, 0, 100 input ac, "Mask Choke", slider, 0, 0, 100 input ib, "Amount", slider, 25, 0, 100 input op, "Opacity", slider, 50, 0, 100 InformationFlag("YUVaware") code // *************** global variables ************** float w,h,i,j,l1,l2,clut[256]; dimensionsof(dest,w,h); image buf1[w][h],buf2[w][h]; // *************** select highlights ************** l1 = ts*(1-(tl/100)); if l1 < 0 l1 = 0; end if; for i = 0 to l1 clut[i] = 0; next; j = 1; for i = l1+1 to ts-1 clut[i] = j++ / (ts-l1); next; for i = ts to 255 clut[i] = 1; next; levelmap(src1, buf1, clut, clut, clut, clut); desaturate(buf1,buf1); // *************** blur mask ************** blur(buf1,buf2,ab,aspectof(buf2)); // *************** choke mask ************** for i = 0 to 254 - ac clut[i] = i / (255 - ac); next; for i = 255 - ac to 255 clut[i] = 1; next; levelmap(buf2, buf2, clut, clut, clut, clut); // *************** blur image ************** blur(src1,buf1,ib,aspectof(buf1)); channelcopy(buf2,buf1,kred,knone,knone,knone); // *************** create composite ************** if apply==1; matte(buf1, src1, dest, op/100, kalpha); end if if apply==2; add(src1, buf1, dest, op/100, kalpha); end if if apply==3; subtract(src1, buf1, dest, op/100, kalpha); end if if apply==4; difference(src1, buf1, dest, kalpha); end if if apply==5; multiply(src1, buf1, dest, op/100, kalpha); end if if apply==6; screen(src1, buf1, dest, op/100, kalpha); end if if apply==7; overlay(src1, buf1, dest, op/100, kalpha); end if if apply==8; darken(src1, buf1, dest, op/100, kalpha); end if if apply==9; lighten(src1, buf1, dest, op/100, kalpha); end if