RGB Shift

RGB Shift CI Filter for Quartz Composer.

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: , , ,

One Response to “RGB Shift”

  1. Markus Says:

    Hi Tom,

    I just found this page and I was looking for a solution to split an image into its rgb components (like the channels in photoshop). What steps would I need to make to use your coding (above) to get 3 output images (each channel as a separate output).

    Thanks a lot,
    Markus

Leave a Reply