Vortex Hydra
From Adobe Labs
/*****************************************************************************
*
* Author: Jan Van Coppenolle
* http://compiler.kaustic.com/lab
*
*****************************************************************************/
kernel Vortex
{
// for the most part based on code by Jerry Huxtable
parameter float2 size
<
minValue: float2(0.0, 0.0);
maxValue: float2(600.0, 400.0);
defaultValue: float2(300.0, 200.0);
>;
parameter float2 center
<
minValue: float2(0.0, 0.0);
maxValue: float2(300.0, 200.0);
defaultValue: float2(150.0, 100.0);
>;
void evaluatePixel(in image4 src, out pixel4 dst)
{
float2 coord = outCoord();
float dx = coord.x - center[0];
float dy = coord.y - center[1];
float d2 = dx * dx + dy * dy;
coord.x = center[0] + center[0] * center[0] * dx / d2;
coord.x = mod(coord.x, size[0]);
coord.y = center[1] + center[1] * center[1] * dy / d2;
coord.y = mod(coord.y, size[1]);
dst = sampleNearest(src, coord);
}
}