23
Nov
07

zoomDistort

I had a brainwave while adding a simple zoom effect (using code from the guys at Vidvox) to another effect:
What would happen if I used the brightness value from the input image, or another image, to alter the zoom level on a per-pixel basis?

The results (with a few extra tweaks and additions) are intriguing.

tb zoomDistort

The hastily slapped-together CIKernel code looks like this:

kernel vec4 tb_zoomDistort(sampler Image, sampler Distortion, vec2 Center, float Level, float DistLevel)
{
vec2 loc;
vec2 modifiedCenter;
Center.x = Center.x / 2.0;
Center.y = Center.y / 2.0;

vec4 pix = sample(Distortion, samplerCoord(Distortion));
float offset = ((pix.r + pix.g + pix.b) / 3.0) * DistLevel;

float Level = Level + offset;

loc = destCoord();
loc = samplerTransform(Image, loc);
modifiedCenter = samplerTransform(Image, Center);
loc = (loc – modifiedCenter) * (1.0 / Level) + modifiedCenter;
return sample(Image, loc);
}

About these ads

0 Responses to “zoomDistort”



  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

November 2007
M T W T F S S
    Dec »
 1234
567891011
12131415161718
19202122232425
2627282930  

Links

Blog Stats

  • 401,092 hits

Follow

Get every new post delivered to your Inbox.

Join 36 other followers

%d bloggers like this: