kernel RGBDistortion < namespace : "com.numeda.display.filters.pbj.RGBDistortion"; vendor : "Numeda / Jonathan Hart / synja.com / jonathan.hart@gmail.com"; version : 1; description : "RGB Displacement"; > { parameter float3 intensityRGB < minValue: float3(0.0, 0.0, 0.0); maxValue: float3(10.0, 10.0, 10.0); defaultValue: float3(5.0,0.0,7.0); >; parameter float3 directionRGB < minValue: float3(-1.0,-1.0,-1.0); maxValue: float3(1.0,1.0,1.0); defaultValue: float3(-1.0,0.0,1.0); >; parameter float3 frequencyRGB < minValue: float3(0.0,0.0,0.0); maxValue: float3(1); defaultValue: float3(0.1,0.1,0.1); >; input image4 src; output pixel4 dst; void evaluatePixel() { float2 orig = outCoord(); dst = sampleLinear(src,orig); float2 displaceR = float2(orig.x-(intensityRGB.r*directionRGB.r)+(sin(orig.y*frequencyRGB.r)*intensityRGB.r), orig.y); float2 displaceG = float2(orig.x-(intensityRGB.g*directionRGB.g)+(sin(orig.y*frequencyRGB.g)*intensityRGB.g), orig.y); float2 displaceB = float2(orig.x-(intensityRGB.b*directionRGB.b)+(sin(orig.y*frequencyRGB.b)*intensityRGB.b), orig.y); pixel4 red = sampleLinear(src, displaceR); pixel4 green = sampleLinear(src, displaceG); pixel4 blue = sampleLinear(src,displaceB); dst.r = red.r; dst.g = green.g; dst.b = blue.b; dst.a = clamp(red.a+green.a+blue.a,0.0,1.0); } }