Hi List,
I recently was looking for a spin blur. Since there wasn't one available
I tried on my own with a Core Image Filter.
The spin blur then is achieved by motion blurring the polar coordinate
representation of the image.
Since there is no wrapping of the blur this leads to an edge.
In my case I overcome this by blurring two halves, one of which is shifted
and then blending them back together with a mask.

Having a Core Image Accumulator after (cartToPol and polToCart) made it
behave much nicer.
So maybe there's something wrong with my filters, but for my specific
composition it works and I'm happy I accomplished this since I had no GLSL
or Core Image experience. And when it comes to rotation and phase I
basically tried a lot around till it fitted in the final picture. Maybe
there's some unneccessity in it that I backtransform later in the
composition.

So here are the two filters:

kernel vec4 cartToPol(sampler src)
{
vec2 newPosition;
float xd, yd,  xs, ys; // destination, source
float phi, r, halfDiagonalLength;
float width = samplerSize(src).x;
float height = samplerSize(src).y;
 halfDiagonalLength = sqrt( .25*width*width + .25*height*height );

xd = destCoord().x; yd = destCoord().y;
phi = (xd/width)*2.0*3.1416;
r = (yd/height)*halfDiagonalLength;
 xs = .5 * width + sin(phi)*r;
ys = .5 * height + cos(phi)*r;
 newPosition.x = xs;
newPosition.y = ys;
return sample(src, newPosition);
}


kernel vec4 polToCart(sampler src)
{
vec2 newPosition;
float xd, yd,  xs, ys; // destination, source
float phi, r, halfDiagonalLength;
float width = samplerSize(src).x;
float height = samplerSize(src).y;
 halfDiagonalLength = sqrt( .25*width*width + .25*height*height );

xd = -.5 * width + destCoord().x;
yd = -.5 * height + destCoord().y;
phi = atan(yd, xd);
r = sqrt( xd*xd + yd*yd );
 xs = ((phi+3.1416)/(2.0*3.1416))* width;
ys = r/halfDiagonalLength * height;
 newPosition.x = xs;
newPosition.y = ys;
return sample(src, newPosition);
}
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Quartzcomposer-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/quartzcomposer-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to