RGB Shift

RGB Shift CI Filter for Quartz Composer.

rgb-shifted-dots

Kernel:

kernel vec4 RGBEffect(sampler image, vec2 offset)
{
	vec2 coord = destCoord();
	float r = sample(image, samplerTransform(image, coord - offset)).r;
	vec2 ga = sample(image, samplerTransform(image, coord)).ga;
	float b = sample(image, samplerTransform(image, coord + offset)).b;
	return vec4(r, ga[0], b, ga[1]);
}
 

Filter Function:

function myROIFunction(samplerIndex, dstRect, offset) {
   var roiRect = new Vec(dstRect);
   var extra = new Vec(Math.abs(offset.x), Math.abs(offset.y));
   if (dstRect.x > extra.x)
   	roiRect.x -= extra.x;
   if (dstRect.y > extra.y)
   	roiRect.y -= extra.y;
   roiRect.z += extra.x;
   roiRect.w += extra.y;
   return roiRect;
}
 
RGBEffect.ROIHandler = myROIFunction;
 
function __image main(__image image, __number amount, __number angle) {
   s = amount / 2;
   offset = new Vec(s * Math.cos(angle), s * Math.sin(angle));
   return RGBEffect.apply(image.definition, offset, image, offset);
}

 

Download (qcFX for VDMX)

Tags: , , ,

Leave a Reply