kernel Genie < namespace : "DN"; vendor : "DN"; version : 1; description : "genie distortion effect"; > { input image4 src; output pixel4 dst; parameter float height < minValue: 0.0; maxValue:4000.0; defaultValue:375.0; >; parameter float width < minValue: 0.0; maxValue:4000.0; defaultValue:500.0; >; parameter float lampPosition < minValue: 10.0; maxValue:1000.0; defaultValue:300.0; >; parameter float time < minValue: 0.0; maxValue:1.0; defaultValue:0.0; >; parameter float lampWidth < minValue: 0.0; maxValue:100.0; defaultValue:10.0; >; void evaluatePixel() { float2 pos = outCoord(); float x1 = 0.0; float x2 = 1.0; float y2 = 1.0; float y1 = 0.0; float4 lp = float4(0.0,0.0,0.0,0.0); float4 rp = float4(0.0,0.0,0.0,0.0); float4 colorAccumulator = float4(0.0, 0.0, 0.0, 0.0); if (time < 0.4) { lp.q = (time*((lampPosition - lampWidth/2.0)/ width)/0.4) ; rp.q = 1.0 + (time*((lampPosition + lampWidth/2.0)/ width - 1.0)/0.4) ; y1 = 0.0; } else { lp.q = (lampPosition - lampWidth/2.0) / width; rp.q = (lampPosition + lampWidth/2.0) / width; y1 = 1.0 - 1.0 / 0.6 * (1.0 - time); } lp.p = 0.90*lp.q; lp.t = 0.25*lp.q; lp.s = 0.0; rp.p = 1.25*rp.q; rp.t = 1.0-(rp.q - rp.p - lampWidth/2.0/width); rp.s = 1.0; lp = smoothStep(float4(0), float4(1), lp ); rp = smoothStep(float4(0), float4(1), rp ); float nY = pos.y/height; float b0 = pow(1.0 - nY, 3.0); float b1 = 3.0 * nY * pow(1.0-nY, 2.0); float b2 = 3.0 * nY * nY * (1.0-nY); float b3 = pow(nY, 3.0); x1 = b0*lp.s + b1*lp.t + b2*lp.p + b3*lp.q; x2 = b0*rp.s + b1*rp.t + b2*rp.p + b3*rp.q; pos = float2((pos.x/width- x1)/(x2 - x1) * width, (nY - y1)/(y2 - y1) * height); //simple box blur colorAccumulator += sampleNearest(src, pos); colorAccumulator += sampleNearest(src, float2(pos.x - 0.5, pos.y)); colorAccumulator += sampleNearest(src, float2(pos.x + 0.5, pos.y)); colorAccumulator += sampleNearest(src, float2(pos.x , pos.y - 0.5)); colorAccumulator += sampleNearest(src, float2(pos.x , pos.y + 0.5)); dst = colorAccumulator / 5.0; } }