kernel TechnoTwirl < // filter: "TechnoDots"; // nameSpace: "popforge::ImageProcessing"; // vendor: "joa ebert"; // version: 1; // description: "like a pixelate filter but using nice dots with spacing"; // filter: "Twirl"; // nameSpace: "popforge::ImageProcessing"; // vendor: "joa ebert"; // version: 1; // description: "applies twirl displacement map"; mashup: "TechnoTwirl"; nameSpace: "ebod@"; vendor: "mangler"; version: 1; description: "mashup of the Twirl and TechnoDot filters written by joa ebert"; > { parameter float spacing < minValue: float(0.0); maxValue: float(16.0); defaultValue: float(2.0); >; parameter float radius < minValue: float(1.0); maxValue: float(64.0); defaultValue: float(4.0); >; parameter float angle < minValue: -20.000; maxValue: 20.000; defaultValue: 0.000; >; parameter pixel4 fillColor < minValue: pixel4(0.0, 0.0, 0.0, 0.0); maxValue: pixel4(1.0, 1.0, 1.0, 1.0); defaultValue: pixel4(0.0, 0.0, 0.0, 1.0); >; void evaluatePixel(in image4 source, out pixel4 sink) { float2 xy0 = outCoord(); float2 xy1 = xy0; // aabb of dot with spacing float rs = radius * 2.0 + spacing; // shift into square xy1 -= mod( xy1, float2(rs, rs) ); // put into the middle xy1 += float2(radius); if (length(xy0 - xy1) > radius) sink = fillColor; else { float2 center = xy1; float2 delta = xy0 - center; float d = length(delta); float r = radius; float phi = atan(delta.y, delta.x) + angle * (r - d) / r; xy1 = center + float2(d * cos(phi), d * sin(phi)); pixel4 c0 = sampleLinear(source, xy0); pixel4 c1 = sampleLinear(source, xy1); sink = (d < r)? c1: c0; } } }