kernel NewFilter < nameSpace : "your namespace"; vendor : "your vendor"; version : 1; description : "your description"; > { parameter float2 topLeft ; parameter float2 bottomRight ; parameter float2 p0 ; parameter float2 p1 ; parameter float2 p2 ; parameter float2 p3 ; void evaluatePixel(in image4 source, out pixel4 result) { float width = bottomRight.x - topLeft.x; float height = bottomRight.y - topLeft.y; float a = ( -p0.x + p1.x ) / width; float b = ( -p0.x + p3.x ) / height; float c = ( p0.x - p1.x + p2.x - p3.x ) / ( width * height ); float d = p0.x; float e = ( -p0.y + p1.y ) / width; float f = ( -p0.y + p3.y ) / height; float i = ( p0.y - p1.y + p2.y - p3.y ) / ( width * height ); float j = p0.y; float2 coord = outCoord(); float2 tmp = outCoord(); coord.x = a * tmp.x + b * tmp.y + c * tmp.x * tmp.y + d; coord.y = e * tmp.x + f * tmp.y + i * tmp.x * tmp.y + j; result = sampleNearest(source,coord); } }