topical media & game development
graphic-player-10-pixel-filter-shaders-Vortex.pbk / pbk
<languageVersion: 1.0;> // The languageVersion is required in PixelBender files. This was added in the 2nd pre-release, and MUST be declared on the first line (comments excluded)
kernel Vortex
<
namespace: "For the most part based on code by Jerry Huxtable";
vendor: "";
version: 1;
description: "A cool vortext kaliedoscope effect.";
>
{
input image4 src;
output pixel4 dst;
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(0.0, 0.0);
>;
void evaluatePixel()
{
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);
}
}
(C) Æliens
20/2/2008
You may not copy or print any of this material without explicit permission of the author or the publisher.
In case of other copyright issues, contact the author.