/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2012
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/
SAMPLE: QameraLackOfRabbitEars.qtzThis kernel takes an input image and a mask image. Using only the center vertical stripe from the mask, the kernel smears the left hand side of the image using the amount of the mask luminance as the offset.
kernel vec4 msBlackVideoSmear(sampler input_image, sampler mask_image)
{
vec2 pixel_size = samplerSize(input_image);
vec2 maxel_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
vec2 maxel_coord = samplerCoord(mask_image);
maxel_coord.x = maxel_size.x * 0.5;
vec4 maxel = sample(mask_image, maxel_coord);
float disturb = clamp(0.333*(maxel.r+maxel.g+maxel.b),0.0,1.0);
vec2 normal_coord = pixel_coord/pixel_size;
float distance_from_left = (1.0-normal_coord.x);
float distance_from_left_sq = distance_from_left* distance_from_left;
float normal_coord_x = clamp(distance_from_left_sq*(disturb+normal_coord.x),0.0,1.0);
float blend_modified = distance_from_left_sq;
float blend_original = 1.0-blend_modified;
normal_coord.x = (blend_modified*normal_coord_x) + (blend_original* normal_coord.x);
vec2 pel_coord = clamp(normal_coord*pixel_size,vec2(0.0),pixel_size);
vec4 pel = sample(input_image, pel_coord);
return pel;
}
Labels: warping