28
Nov
07

zoomDistort Variation

I’ve been tweaking the zoomDistort code, and have added seperate zooming for the Red, Green and Blue channels.

The zoom kernel code is very similar to the zoomRGB FX, with a couple of extra lines added to handle the brightness values from the input image.

/*
Zoom kernel courtesy of Vidvox
http://vidvox.net/phpBB2/viewtopic.php?t=1785&sid=1c5efa0005881bf0dc59f84b3498a7ed
*/

kernel vec4 tb_zoomDistort_RGB(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 zoomR = Level + (pix.r * DistLevel);
float zoomG = Level + (pix.g * DistLevel);
float zoomB = Level + (pix.b * DistLevel);

loc = destCoord();
loc = samplerTransform(Image, loc);

modifiedCenter = samplerTransform(Image, Center);

vec2 locR = (loc – modifiedCenter) * (1.0 / zoomR) + modifiedCenter;
vec2 locG = (loc – modifiedCenter) * (1.0 / zoomG) + modifiedCenter;
vec2 locB = (loc – modifiedCenter) * (1.0 / zoomB) + modifiedCenter;

vec4 pix;
pix.r = sample(Image, locR).r;
pix.g = sample(Image, locG).g;
pix.b = sample(Image, locB).b;
pix.a = 1.0;

return pix;
}

Currently, the controls are a bit, well, uncontrollable. I’ll have to work out some sensible scaling for them at some point (maybe with some exponential sliders).

zoomDistort RGB 01

zoomDistort RGB 02

Advertisements

0 Responses to “zoomDistort Variation”



  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

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

Links

Blog Stats

  • 467,455 hits

%d bloggers like this: