My simplest effect yet. Simply mixes from original image to two different channel-shifted variants, then back to the original image.
The key is the ‘.’ swizzle operator, which allows the Red Blue, Green and Alpha channels of the image to be rearranged. Also notice that the Mix variable goes from 0.0 to just less than 3.0, and I use the fract function to extract the part of the number after the decimal point, and use this to mix between 2 variants, as well as to swap the start and end of the mix operation with values above 1.0 and 2.0.
Simple, but cool.
Image: input image
Mix: mix between original and channel-shifted variants. Range 0.0 > 2.999
kernel vec4 swizzler(sampler Image, float Mix)
vec4 pix = unpremultiply(sample(Image, samplerCoord(Image)));
vec4 outPix = (Mix <= 1.0) ? mix(pix.rgba, pix.brga, fract(Mix)) : (Mix <= 2.0) ? mix(pix.brga, pix.gbra, fract(Mix)) : mix(pix.gbra, pix.rgba, fract(Mix)); return premultiply(outPix); }[/code]