B-L-A-C-K-O-P
 
 
Saturday, November 21, 2009
Quartz Composer Patch : Gradient Wipe Attempt
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: GradientWipe.qtzThis kernel takes two input images and a numeric value between 0 and 1 and creates a gradient wipe. First attempt. Linear.

kernel vec4 msBlackSinCityColorReplacement(sampler input_image, sampler input_mask, float position)
{
float input_position = clamp(position,0.0,1.0);
vec2 image_size = samplerSize(input_image);
vec2 image_xy = samplerCoord(input_image);
float position_x = (image_xy.x/image_size.x)*32.;
vec4 image_rgba0 = unpremultiply(sample(input_image, samplerCoord(input_image)));
vec4 mask_rgba1 = unpremultiply(sample(input_mask, samplerCoord(input_mask)));

float alpha = input_position*position_x; /* for vertical, use position_y */
vec4 result = image_rgba0*alpha + mask_rgba1*(1.0-alpha);
return result;
}

Labels: ,

By : Ms. Black Gradient Wipe Attempt 0 comments

Saturday, January 12, 2008
Quartz Composer Patch : Super Tile with Mask
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraLotsOfHearts.qtzThis kernel applies the mask_image ala msBlackMergeAlphaFromGrey and then tiles the image to input_subdivisions.

kernel vec4 msBlackSuperTileMask(sampler input_image, sampler mask_image, float input_subdivisions)
{
float subdivisions = (input_subdivisions);
/* float subdivisions = int(input_subdivisions); */ // for discrete subdivisions
vec2 image_size = samplerSize(input_image);
vec2 mask_size = samplerSize(mask_image);
vec2 box_size = floor(image_size/subdivisions);
vec2 pixel_coord = samplerCoord(input_image);
vec2 maxel_coord = samplerCoord(mask_image);
vec2 box_coord = mod(pixel_coord,box_size)*subdivisions;
vec2 normal_coord = mod(pixel_coord,box_size)/box_size;
vec2 mask_coord = normal_coord*mask_size;
vec4 pixel = sample(input_image, box_coord);
vec4 maxel = sample(mask_image, mask_coord);
pixel.a = clamp((maxel.x+maxel.y+maxel.z)/3.0,0.0,1.0);
return pixel;
}

Labels:

By : Ms. Black Super Tile with Mask 0 comments

Quartz Composer Patch : Sawtooth Mask
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraVHSPlayBack.qtzThis kernel evaluates the sawtooth waveform at each vertical pixel location, x, and computes the alpha based on the value of the function at that point.


const float M_PI = 3.1415926535897932384;
const float period_degrees = 180.0;

float inverse_saw(float in_angle_degrees)
{
float angle_degrees = clamp(in_angle_degrees,0.0, period_degrees);
float value_normal = angle_degrees/period_degrees;
float value_if_nz = (value_normal*2.0 - 1.0);
float value = (angle_degrees==0.0) ? 0.0 : -1.0*value_if_nz;
return value;
}

kernel vec4 msBlackHorizontalSawMask(sampler input_image, float input_frequency, float input_amplitude, float input_offset, float input_phase)
{
vec2 image_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
vec4 pixel = sample(input_image, pixel_coord);
float pixel_y_normal = pixel_coord.y/image_size.y;
float degrees = (pixel_y_normal* period_degrees);
float phase = clamp(input_phase* period_degrees,0.0, period_degrees);
float alpha = input_offset + (input_amplitude * mod(phase+input_frequency* inverse_saw(degrees),1.0));
pixel.a = alpha*pixel.a;
return vec4(clamp(pixel, 0.0, 1.0));
}

Labels: ,

By : Ms. Black Sawtooth Mask 0 comments

Quartz Composer Patch : Desaturate and Invert, Alpha Unchanged
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraWaffleMatrix.qtzThis kernel desaturates the image and inverts it. Very useful as pre-filter for msBlackMergeAlphaFromGrey.

kernel vec4 msBlackInvertRGBLeaveAlpha(sampler input_image)
{
vec4 pixel = sample(input_image, samplerCoord(input_image));
float average = 1.0-clamp((pixel.x+ pixel.y+ pixel.z)/3.0,0.0,1.0);
pixel.r = average;
pixel.g = average;
pixel.b = average;
return pixel;
}

Labels: ,

By : Ms. Black Desaturate and Invert, Alpha Unchanged 0 comments

Quartz Composer Patch : Horizontal Video Smear
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
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:

By : Ms. Black Horizontal Video Smear 0 comments

Thursday, January 10, 2008
Quartz Composer Patch : Subdivision Tilings with Mask
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraSuperTiling.qtzSimilar to Subdivision Tiles, but with a mask image that is applied in source coordinate space.

kernel vec4 msBlackSuperTileMask(sampler input_image, sampler mask_image, float input_subdivisions)
{
float subdivisions = int(input_subdivisions/2.0);
vec2 image_size = samplerSize(input_image);
vec2 mask_size = samplerSize(mask_image);
vec2 box_size = floor(image_size/subdivisions);
vec2 pixel_coord = samplerCoord(input_image);
vec2 maxel_coord = samplerCoord(mask_image);
vec2 box_coord = mod(pixel_coord,box_size)*subdivisions;
vec2 normal_coord = mod(pixel_coord,box_size)/box_size;
vec2 mask_coord = normal_coord*mask_size;
vec4 pixel = sample(input_image, box_coord);
vec4 maxel = sample(mask_image, mask_coord);
pixel.a = clamp((maxel.x+maxel.y+maxel.z)/3.0,0.0,1.0);
return pixel;
}

Labels: ,

By : Ms. Black Subdivision Tilings with Mask 0 comments

Quartz Composer Patch : Subdivision "Tiling"
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: Qamera80sGreenGrid3.qtzThis kernel tiles an image into n-subdivisions. Personally, I find the replicate patch to be somewhat annoying to use. For 2D tilings, this may be useful.

kernel vec4 msBlackSuperTile(sampler input_image, float input_subdivisions)
{
float subdivisions = int(input_subdivisions/2.0);
vec2 image_size = samplerSize(input_image);
vec2 box_size = floor(image_size/subdivisions);
vec2 pixel_coord = samplerCoord(input_image);
vec2 box_coord = mod(pixel_coord,box_size)*subdivisions;
vec4 pixel = sample(input_image, box_coord);
return pixel;
}

Labels:

By : Ms. Black Subdivision "Tiling" 0 comments

Quartz Composer Patch : Texture "Phase"
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: Qamera80sGreenGrid3.qtzThis takes normal inputs [0...1] for both x and y, and computes new image in texture "phase" space.

kernel vec4 msBlackTexPhase(sampler input_image, float input_phase_x, float input_phase_y)
{
float phase_x = clamp(input_phase_x,0.0,1.0)-0.5;
float phase_y = clamp(input_phase_y,0.0,1.0)-0.5;
vec2 image_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
vec2 normal_coord = pixel_coord/image_size;
normal_coord += vec2(phase_x,phase_y);
vec2 pel_coord = mod(normal_coord*image_size,image_size);
vec4 pel = sample(input_image, pel_coord);
return pel;
}

Labels:

By : Ms. Black Texture "Phase" 0 comments

Quartz Composer Patch : Color Distortion Maps, YUV
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraYUVMunge.qtzThis kernel distorts the color in the image using two source image "maps". Each image map is evaluated as a greyscale value. This results in an average brightness from 0.0 ... 1.0. Using 0.5 as the center, the source pixel is adjusted in the U and V color axes by the displacements from the maps. The effect is blended back into the source pixel according to amount_normal.

kernel vec4 msBlackColorDisplaceYUV(sampler image, sampler distort_u_map, sampler distort_v_map, float amount_normal)
{
float input_amount = clamp(amount_normal,0.0,1.0);
float inverse_amount = 1.0-input_amount;
const vec3 rgb_y = vec3(0.257, 0.504, 0.098);
const vec3 rgb_u = vec3(-0.148, -0.291, 0.439);
const vec3 rgb_v = vec3(0.439, -0.368, -0.071);
const vec3 yuv_r = vec3(1.0000, 0.0000, 1.4022 );
const vec3 yuv_g = vec3( 1.0000, -0.3457, -0.7145);
const vec3 yuv_b = vec3(1.0000, 1.7710, 0.0000);

vec4 pixel = sample(image, samplerCoord(image));
vec3 pel = pixel;
vec3 distort_u = sample(distort_u_map, samplerCoord(distort_u_map));
vec3 distort_v = sample(distort_v_map, samplerCoord(distort_v_map));

float delta_u = clamp((distort_u.x+distort_u.y+distort_u.z)/3.0,0.0,1.0)-0.5;
float delta_v = clamp((distort_v.x+distort_v.y+distort_v.z)/3.0,0.0,1.0)-0.5;
vec3 pixel_yuv;
pixel_yuv.x = dot(pel,rgb_y);
pixel_yuv.y = dot(pel,rgb_u);
pixel_yuv.z = dot(pel,rgb_v);

pixel_yuv.y = clamp(pixel_yuv.y + delta_u,0.0,1.0);
pixel_yuv.z = clamp(pixel_yuv.z + delta_v,0.0,1.0);

pel.r = dot(pixel_yuv,yuv_r);
pel.g = dot(pixel_yuv,yuv_g);
pel.b = dot(pixel_yuv,yuv_b);

vec3 result = (input_amount*pel) + inverse_amount*vec3(pixel);

return vec4(result.r, result.g, result.b,pixel.a);
}

Labels:

By : Ms. Black Color Distortion Maps, YUV 0 comments

Friday, January 4, 2008
Quartz Composer Patch : Soft Radial Mask
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: Qamera3DFloatingQubes.qtzThis kernel calculates the alpha of the image based on the distance from the center. The mask fades out according to the input_fade_power.

kernel vec4 msBlackRadialPowerMask(sampler input_image, float input_max_radius, float input_fade_power)
{
vec2 image_size = samplerSize(input_image);
vec2 image_center = image_size*0.5;
vec2 pixel_coord = samplerCoord(input_image);
float pel_distance = distance(pixel_coord,image_center);
vec4 pixel = sample(input_image, pixel_coord);
float distance_ratio = clamp(pel_distance/input_max_radius,0.0,1.0);
float alpha = clamp(1.0-(pow(distance_ratio,input_fade_power)),0.0,1.0);
pixel.a = alpha;
return pixel;
}

Labels: ,

By : Ms. Black Soft Radial Mask 0 comments

Quartz Composer Patch : Soft Rectangular Mask
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: Qamera3DDiscoDanceFloor.qtzThis Kernel makes a rectangular mask inset input_pixels from the edge of the source image, and attenuated by the input_fade_power.

float radians_from_degrees(const float in_degrees)
{
const float M_PI = 3.1415926535897932384;
return in_degrees * (M_PI/180.0);
}

kernel vec4 msBlackSoftBoxMask(sampler input_image, float input_pixels, float input_angle_degrees, float input_fade_power)
{
vec2 image_size = samplerSize(input_image);
vec2 image_center = image_size*0.5;
vec2 pixel_coord = samplerCoord(input_image);
vec2 pixel_xy = pixel_coord-image_center;
float theta = radians_from_degrees(input_angle_degrees);
float cos_theta = cos(theta);
float sin_theta = sin(theta);
vec2 rotate_x = vec2(cos_theta,-sin_theta);
vec2 rotate_y = vec2(sin_theta,cos_theta);
float xx = dot(rotate_x, pixel_xy);
float yy = dot(rotate_y, pixel_xy);
pixel_coord = image_center + vec2(xx,yy);
float dist_top = abs(pixel_coord.y-0.0);
float dist_left = abs(pixel_coord.x-0.0);
float dist_right = abs(image_size.x-pixel_coord.x);
float dist_bottom = abs(image_size.y-pixel_coord.y);
vec4 pixel = sample(input_image,samplerCoord(input_image));
const float opaque = 1.0;
float alpha = opaque;
const float power = input_fade_power;
float semi_transparent_left = clamp(pow(dist_left/input_pixels,power),0.0,1.0);
alpha = (dist_left<input_pixels) ? min(semi_transparent_left,alpha): alpha;

float semi_transparent_top = clamp(pow(dist_top/input_pixels,power),0.0,1.0);
alpha = (dist_top<input_pixels) ? min(semi_transparent_top,alpha): alpha;

float semi_transparent_right = clamp(pow(dist_right/input_pixels,power),0.0,1.0);
alpha = (dist_right<input_pixels) ? min(semi_transparent_right,alpha) : alpha;

float semi_transparent_bottom = clamp(pow(dist_bottom/input_pixels,power),0.0,1.0);
alpha = (dist_bottom<input_pixels) ? min(semi_transparent_bottom,alpha) : alpha;

pixel.a = alpha;
return pixel;
}

Labels: ,

By : Ms. Black Soft Rectangular Mask 0 comments

Quartz Composer Patch : Sin City Style Color FX
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraSinCityRed.qtzThis kernel simulates a Sin City 1-color only type camera effect. It takes a "find_color" and a "replace_color". It samples each pixel in the source image and calculates the distance (in the RGB cube) from find_color. If the source pixel is within the threshold distance from the find_color, the kernel replaces the pixel in the output image with the replace_color; otherwise, it desaturates the pixel. In the sample, we've mapped the find_color and replace_color to the same color. But if you watch Robert Rodriquez's 15min film school, you will see they used YELLOW as the find_color and RED as the replace color in many situations. Also the sample QTZ has the sensitivity on a LFO to handle different lighting conditions.

kernel vec4 msBlackSinCityColorReplacement(sampler image, float input_threshold_normal, float threshold_sensitivity, __color find_color, __color replace_color)
{
float input_threshold_sensitivity = 2.*(1.0-clamp(threshold_sensitivity,0.0,1.0));
float input_threshold = clamp(pow(input_threshold_normal, input_threshold_sensitivity),0.0,1.0);
vec3 pel_rgb = unpremultiply(sample(image, samplerCoord(image)));
vec3 find_pel = vec3(find_color.r,find_color.g,find_color.b);
vec4 replace_pel = vec3(replace_color.r, replace_color.g, replace_color.b);
replace_pel.a = 1.0;
float distance_in_rgb_cube = distance(find_pel,pel_rgb);
float distance_abs = sqrt(distance_in_rgb_cube*distance_in_rgb_cube);
vec4 pel_avg = (pel_rgb.r + pel_rgb.g + pel_rgb.b)/3.0;
vec4 result = (distance_abs <input_threshold) ? replace_pel : pel_avg;
return result;
}

Labels:

By : Ms. Black Sin City Style Color FX 0 comments

Quartz Composer Patch : Polar Displacement Maps
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraGlassBeerBottles.qtzThis takes two input images in addition to the primary image input. It samples the delta(radius) and delta(theta) from the displacement maps and then distorts the sample coordinate of the source image by the polar offset given by radius and theta.


float as_radians(const float in_degrees)
{
return in_degrees * (3.14597/180.0);
}

vec2 from_polar(const float in_radius, const float in_theta)
{
float x = in_radius * sin(as_radians(in_theta));
float y = in_radius * cos(as_radians(in_theta));
return vec2(x,y);
}

kernel vec4 msBlackDisplacementMaps(sampler input_image, sampler input_map_radius, sampler input_map_angle, float input_range_normal)
{
float input_range = clamp(input_range_normal,0.0,1.0);
vec2 image_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
vec4 maxel_radius = sample(input_map_radius, samplerCoord(input_map_radius));
vec4 maxel_angle = sample(input_map_angle, samplerCoord(input_map_angle));
float dr_normal = input_range*dot(vec3(maxel_radius),vec3(maxel_radius));
float dt_normal = dot(vec3(maxel_angle),vec3(maxel_angle));
float radius = dr_normal*max(image_size.x, image_size.y);
float angle = dt_normal*360.0;
pixel_coord += from_polar(radius, angle);
return sample(input_image, pixel_coord);
}

By : Ms. Black Polar Displacement Maps 0 comments

Quartz Composer Patch : Rectangular Displacement Maps
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraGlassDecoBricks.qtzThis takes two input images in addition to the primary image input. It samples the dx and dy from the displacement maps and then distorts the sample coordinate of the source image by (dx,dy). This kernel can generate an extremely wide variety of distortion effects simply by manipulating the 2D map images. We're getting everything from glass effects to "Chuck Close" style halftone effects.

kernel vec4 msBlackDisplacementMaps(sampler input_image, sampler input_map_x, sampler input_map_y, float input_range_normal)
{
float input_range = clamp(input_range_normal,0.0,1.0);
vec2 image_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
vec4 maxel_x = sample(input_map_x, samplerCoord(input_map_x));
vec4 maxel_y = sample(input_map_y, samplerCoord(input_map_y));
float dx_normal = input_range*dot(vec3(maxel_x),vec3(maxel_x));
float dy_normal = input_range*dot(vec3(maxel_y),vec3(maxel_y));
pixel_coord.x += dx_normal * image_size.x;
pixel_coord.y += dy_normal * image_size.y;
return sample(input_image, pixel_coord);
}

By : Ms. Black Rectangular Displacement Maps 0 comments

Wednesday, January 2, 2008
Quartz Composer Patch : Sine "Wave"
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraTequila.qtzThis filter evaluates sin(x) at each pixel location, calculates a displacement, and then fetches a pixel offset by the sin fn. Waves, and more.

kernel vec4 msBlackVerticalSineWave(sampler input_image, float input_frequency, float input_amplitude_normal, float input_offset, float input_phase)
{
vec2 image_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
float input_amplitude = clamp(input_amplitude_normal,0.0,1.0)*0.1;
float pixel_y_normal = pixel_coord.y/image_size.y;
const float M_PI = 3.14597;
float sin_y = input_offset + (input_amplitude * sin(M_PI*(input_phase+(input_frequency*pixel_y_normal))));

pixel_coord.y += (sin_y * image_size.y);
vec4 pixel = sample(input_image, pixel_coord);
return vec4(clamp(pixel, 0.0, 1.0));
}

By : Ms. Black Sine "Wave" 0 comments

Tuesday, January 1, 2008
Quartz Composer Patch : Lens Flex Distortion
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraConcave.qtz This filter can flex the image in both inward and outward directions. My goal was to have it take normalized parameters and have the two inward and outward flexes to be symmetrical. Didn't quite get it, but close enough.

kernel vec4 msBlackLensFlex(sampler image, vec2 center, float input_factor_normal, float input_sign, float input_scale_normal)
{
vec2 vector = destCoord() - center;
float distance_from_center = length(vector);
vec2 distance_normal = normalize(vector);
float input_factor = clamp(input_factor_normal,0.0,1.0);
float input_scale = -input_sign*((1.0-input_sign)-clamp(input_scale_normal,0.0,1.0));
float distance_sq = distance_from_center*distance_from_center;
vec2 image_size = samplerSize(image);
float max_factor = max(image_size.x,image_size.y);
float lens_factor = abs(input_factor)*max_factor;
float lens_factor_sq = input_sign*lens_factor*lens_factor;
float dxdy = input_scale * distance_from_center / (1.0 - (distance_sq/lens_factor_sq) );
vec2 pixel_offset = center + dxdy * distance_normal;
vec4 pixel = sample(image, samplerTransform(image, pixel_offset));
return pixel;
}

By : Ms. Black Lens Flex Distortion 0 comments

Quartz Composer Patch : Sin(x) Filter, Horizontal
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraRabbitEars.qtzThis kernel calculates the function sin(y) at each location in the source image, and builds a mask based on the evaluation of sin(y). RabbitEars emulates an analog TV, and it uses two of these filters in series.

kernel vec4 msBlackHorizontalSineMask(sampler input_image, float input_frequency, float input_amplitude, float input_offset, float input_phase)
{
vec2 image_size = samplerSize(input_image);
vec2 pixel_coord = samplerCoord(input_image);
vec4 pixel = sample(input_image, pixel_coord);
float pixel_y_normal = pixel_coord.y/image_size.y;
float M_PI = 3.14597;
float alpha = input_offset + (input_amplitude * sin(M_PI*(input_phase+(input_frequency*pixel_y_normal))));
pixel.a = alpha*pixel.a;
return vec4(clamp(pixel, 0.0, 1.0));
}

By : Ms. Black Sin(x) Filter, Horizontal 0 comments

Saturday, December 29, 2007
Quartz Composer Patch : Borrow Alpha Component
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraBondReloaded.qtzThis kernel extracts the alpha channel from the mask image, inverts it, and inserts the alpha channel in the result image. The source RGB values pass through unchanged.

kernel vec4 msBlackBorrowAlpha(sampler image, sampler mask)
{
vec4 pixel = sample(image, samplerCoord(image));
vec4 maxel = sample(mask, samplerCoord(mask));

pixel.a = 1.0-maxel.a;
return pixel;

}

By : Ms. Black Borrow Alpha Component 0 comments

Quartz Composer Patch : Brightness Mapping (RGB)
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraSparklStars2.qtz
This code evaluates each pixel in the mask, extracts the brightness from it, and then adjusts the brightness of the source pixel by the amount of the mask brightness. The input_range value controls the amount of the effect.
kernel vec4 msBlackBrightnessMap(sampler image, sampler mask, float input_range)
{
float range = clamp(input_range+0.1,0.0,1.0);
float inverse_range = 1.0-range;
float brightness;
vec4 pixel = sample(image, samplerCoord(image));
vec3 maxel = sample(mask, samplerCoord(mask));
brightness = range*dot(maxel,maxel);
brightness += inverse_range;

pixel.r *= brightness;
pixel.g *= brightness;
pixel.b *= brightness;

return clamp(pixel,0.0,1.0);
}

By : Ms. Black Brightness Mapping (RGB) 0 comments

Quartz Composer Patch : Andy Warhol Style Silkscreen Filter
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraPosterCamo.qtzThis Core Image kernel creates an Andy Warhol style silkscreen image. Andy used to take polaroids of people, generate a silkscreen mask with the blown up polaroid image, and then silkscreen the black outline over various other colors and so forth. He also hand-painted after silkscreening. Him and his factory of cheap laborers of love. This filter does a pretty good job of it.

kernel vec4 msBlackSilkscreen(sampler input_image, float input_threshold)
{
vec2 center = samplerCoord(input_image);
vec4 pixel = sample(input_image, center);
float normal = dot(vec3(pixel),vec3(pixel));
float grey = clamp(float(normal>input_threshold),0.0,1.0);
float alpha = 1.0-grey;
pixel.r = grey;
pixel.g = grey;
pixel.b = grey;
pixel.a = grey;
return pixel;
}

By : Ms. Black Andy Warhol Style Silkscreen Filter 0 comments

Friday, December 28, 2007
Quartz Composer Patch : Contrast Mapping (YUV)
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraSparklStars.qtz

This kernel extracts the overall brightness of each mask pixel, and applies that brightness level as a contrast adjustment to each source pixel in the input image.


kernel vec4 msBlackContrastMap(sampler image, sampler mask, float input_offset)
{
const vec3 rgb_y = vec3(0.257, 0.504, 0.098);
const vec3 rgb_u = vec3(-0.148, -0.291, 0.439);
const vec3 rgb_v = vec3(0.439, -0.368, -0.071);
const vec3 yuv_r = vec3(1.0000, 0.0000, 1.4022 );
const vec3 yuv_g = vec3( 1.0000, -0.3457, -0.7145);
const vec3 yuv_b = vec3(1.0000, 1.7710, 0.0000);

vec4 pixel = sample(image, samplerCoord(image));
vec3 pel = pixel;
float contrast = 1.0;
vec3 maxel = sample(mask, samplerCoord(mask));
contrast = dot(maxel,maxel);
float clamped_contrast = clamp(contrast+input_offset,0.0,1.0);
vec3 pixel_yuv;
pixel_yuv.x = dot(pel,rgb_y);
pixel_yuv.y = dot(pel,rgb_u);
pixel_yuv.z = dot(pel,rgb_v);

float pixel_x = pixel_yuv.x;
pixel_x *= clamped_contrast;

pixel_yuv.x = pixel_x;
pixel_yuv.y = pixel_yuv.y;
pixel_yuv.z = pixel_yuv.z;

pel.r = dot(pixel_yuv,yuv_r);
pel.g = dot(pixel_yuv,yuv_g);
pel.b = dot(pixel_yuv,yuv_b);

return vec4(pel.r,pel.g,pel.b,pixel.a);
}

By : Ms. Black Contrast Mapping (YUV) 0 comments

Quartz Composer Patch : Tint Mapping
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraRainbow.qtz

This kernel takes a mask image, extracts the chromaticity from the mask, and applies the color to the source image without affecting the luma (brightness). You may want to front-load the input image with a contrast bump and/or desaturate the mask image slightly. Basically, this allows you to "steal" the color from an image without taking the brightness.

kernel vec4 msBlackTintMapping(sampler image, sampler mask)
{
const vec3 rgb_y = vec3(0.257, 0.504, 0.098);
const vec3 rgb_u = vec3(-0.148, -0.291, 0.439);
const vec3 rgb_v = vec3(0.439, -0.368, -0.071);
const vec3 yuv_r = vec3(1.0000, 0.0000, 1.4022 );
const vec3 yuv_g = vec3( 1.0000, -0.3457, -0.7145);
const vec3 yuv_b = vec3(1.0000, 1.7710, 0.0000);

vec4 pixel = sample(image, samplerCoord(image));
vec3 pel = pixel;
vec3 maxel = sample(mask, samplerCoord(mask));

vec3 tint_yuv;
tint_yuv.x = dot(maxel,rgb_y);
tint_yuv.y = dot(maxel,rgb_u);
tint_yuv.z = dot(maxel,rgb_v);

vec3 pixel_yuv;
pixel_yuv.x = dot(pel,rgb_y);
pixel_yuv.y = dot(pel,rgb_u);
pixel_yuv.z = dot(pel,rgb_v);

pixel_yuv.y = tint_yuv.y;
pixel_yuv.z = tint_yuv.z;

pel.r = dot(pixel_yuv,yuv_r);
pel.g = dot(pixel_yuv,yuv_g);
pel.b = dot(pixel_yuv,yuv_b);

return vec4(pel.r,pel.g,pel.b,pixel.a);
}

By : Ms. Black Tint Mapping 0 comments

Quartz Composer Patch : Mask Extraction from Any Image
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraSofterIris.qtzAs I was dissatisfied with the mask extraction/merging available in QC, we wrote this patch to be able to extract a matte, or alpha channel, from just about any source image. The kernel works by taking the dot product of the mask pixel, which ultimately is a normalized distance from black, and migrates that value into the alpha channel of the source image. This kernel works great, we use it everywhere.

kernel vec4 msBlackMergeAlphaFromGrey(sampler image, sampler mask)
{
vec4 pixel = sample(image, samplerCoord(image));
vec4 maxel = sample(mask, samplerCoord(mask));
float maskpel = clamp(0.333 * (maxel.r + maxel.g + maxel.b), 0.0, 1.0);
pixel.a = maskpel;
return pixel;
}


If you need the inverse of the matte, either use this kernel, or run the image through Color Invert before extracting:

kernel vec4 msBlackMergeAlphaFromGrey(sampler image, sampler mask)
{
vec4 pixel = sample(image, samplerCoord(image));
vec4 maxel = sample(mask, samplerCoord(mask));
float maskpel = clamp(0.333 * (maxel.r + maxel.g + maxel.b), 0.0, 1.0);
pixel.a = 1.0 - maskpel;
return pixel;
}

By : Ms. Black Mask Extraction from Any Image 0 comments

Quartz Composer Patch : Cheap Blur 3x3
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

A blur kernel (3x3 convolution, basically) cheap enough to run on !ARBfp hardware ("Quartz Extreme"), circa 2002.

/* cheap, as in !!arbfp cheap */
kernel vec4 msBlackCheapBlur(sampler input_image, float input_radius)
{
float clamped_radius = input_radius;
float delta_x = 1.0 / (0.1+clamped_radius*0.5);
float delta_y = 1.0 / (0.1+clamped_radius*0.5);

vec2 center = samplerCoord(input_image);
vec4 c = sample(input_image, center + vec2(-delta_x,-delta_y));
vec4 bl = sample(input_image, center + vec2(-delta_x,-delta_y));
vec4 l = sample(input_image, center + vec2(-delta_x, 0.0));
vec4 tl = sample(input_image, center + vec2(-delta_x, delta_y));
vec4 t = sample(input_image, center + vec2( 0.0, delta_y));
vec4 ur = sample(input_image, center + vec2( delta_x, delta_y));
vec4 r = sample(input_image, center + vec2( delta_x, 0.0));
vec4 br = sample(input_image, center + vec2( delta_x, delta_y));
vec4 b = sample(input_image, center + vec2( 0.0,-delta_y));
vec4 blur = 0.25 * c + 0.125 * (l + t + r + b) + 0.0625 * (bl + tl + ur + br);
return blur;
}

By : Ms. Black Cheap Blur 3x3 0 comments

Quartz Composer Patch : Blur Mapping
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraWetter.qtzThis kernel takes a mask image, and uses the brightness of the mask pixel as the input to a 3x3 blur kernel. This kernel has proved useful in creating "water on glass" effects. It's derived from msBlackCheapBlur, which is listed elsewhere on this page. One of the reasons that we developed cheap blur (actually, ported from shader fragments in cyberspace) is because Core Image gaussian blur seems to be invoking the software OpenGL renderer on the Intel MacBooks. The performance hit is noticeable, as is the increase in memory bandwidth usage. Mr. Black pointed this out, I am simply relaying the info.

UPDATE: This blur mapping kernel is also exceeding the fragment program limits on the MacBook. More research underway...

kernel vec4 msBlackBlurMap(sampler input_image, sampler input_mask_image)
{
vec3 maxel = sample(input_mask_image, samplerCoord(input_mask_image));
float clamped_radius = dot(maxel,maxel);
float delta_x = 1.0 / (0.1+clamped_radius*0.5);
float delta_y = 1.0 / (0.1+clamped_radius*0.5);
vec2 center = samplerCoord(input_image);
vec4 c = sample(input_image, center + vec2(-delta_x,-delta_y));
vec4 bl = sample(input_image, center + vec2(-delta_x,-delta_y));
vec4 l = sample(input_image, center + vec2(-delta_x, 0.0));
vec4 tl = sample(input_image, center + vec2(-delta_x, delta_y));
vec4 t = sample(input_image, center + vec2( 0.0, delta_y));
vec4 ur = sample(input_image, center + vec2( delta_x, delta_y));
vec4 r = sample(input_image, center + vec2( delta_x, 0.0));
vec4 br = sample(input_image, center + vec2( delta_x, delta_y));
vec4 b = sample(input_image, center + vec2( 0.0,-delta_y));
vec4 blur = 0.25 * c + 0.125 * (l + t + r + b) + 0.0625 * (bl + tl + ur + br);
return blur;
}

By : Ms. Black Blur Mapping 0 comments

Quartz Composer Patch : Image Registration: YUV, Rectangular (dx,dy)
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraBetterPopArt5.qtzThis is similar to the ARGB registration kernels, but it works in YUV color space, where the brightness is already separated from the chromaticity. Thus, when you de-register, the deregistered color is more closely related to the center.

kernel vec4 msBlackRectRegistrationYUV(sampler input_image, vec2 u_delta, vec2 v_delta)
{
const vec3 rgb_y = vec3(0.257, 0.504, 0.098);
const vec3 rgb_u = vec3(-0.148, -0.291, 0.439);
const vec3 rgb_v = vec3(0.439, -0.368, -0.071);
const vec3 yuv_r = vec3(1.0000, 0.0000, 1.4022 );
const vec3 yuv_g = vec3( 1.0000, -0.3457, -0.7145);
const vec3 yuv_b = vec3(1.0000, 1.7710, 0.0000);

vec2 center = samplerCoord(input_image);
vec4 pixel = sample(input_image, center);
vec3 pel = pixel;
vec3 u_pixel = sample(input_image, center + u_delta);
vec3 v_pixel = sample(input_image, center + v_delta);

vec3 pixel_yuv;
pixel_yuv.x = dot(pel,rgb_y);
pixel_yuv.y = dot(u_pixel,rgb_u);
pixel_yuv.z = dot(v_pixel,rgb_v);

pixel.r = dot(pixel_yuv,yuv_r);
pixel.g = dot(pixel_yuv,yuv_g);
pixel.b = dot(pixel_yuv,yuv_b);
return pixel;
}

By : Ms. Black Image Registration: YUV, Rectangular (dx,dy) 0 comments

Quartz Composer Patch : Image Registration: ARGB Rectangular (dx,dy)
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraBetterPopArt2.qtz/* de-register the RGB color planes of an image by r_delta,g_delta,b_delta */
kernel vec4 msBlackRectangularRegistration(sampler input_image, vec2 r_delta, vec2 g_delta, vec2 b_delta)
{
vec2 center = samplerCoord(input_image);
vec4 pixel = sample(input_image, center);
vec4 red = sample(input_image, center + r_delta);
vec4 green = sample(input_image, center + g_delta);
vec4 blue = sample(input_image, center + b_delta);
pixel.r = red.r;
pixel.g = green.g;
pixel.b = blue.b;
return pixel;
}

By : Ms. Black Image Registration: ARGB Rectangular (dx,dy) 0 comments

Quartz Composer Patch : Image Registration: ARGB Polar(radius,theta)
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

SAMPLE: QameraBetterPopArt3.qtz
This Core Image page 'de-registers' the color planes of an image. A common technique among graphic designers when running traditional print jobs. Of course, with PhotoShop, nobody does it at the printer anymore.

float as_radians(const float in_degrees)
{
return in_degrees * (3.14597/180.0);
}

vec2 from_polar(const float in_radius, const float in_theta)
{
float x = in_radius * sin(as_radians(in_theta));
float y = in_radius * cos(as_radians(in_theta));
return vec2(x,y);
}

kernel vec4 msBlackPolarRegistration(sampler input_image, float radius_r, float angle_r, float radius_g, float angle_g, float radius_b, float angle_b)
{
vec2 r_delta = from_polar(radius_r, angle_r);
vec2 g_delta = from_polar(radius_g, angle_g);
vec2 b_delta = from_polar(radius_b, angle_b);

vec2 center = samplerCoord(input_image);
vec4 pixel = sample(input_image, center);
vec4 red = sample(input_image, center + r_delta);
vec4 green = sample(input_image, center + g_delta);
vec4 blue = sample(input_image, center + b_delta);

pixel.r = red.r;
pixel.g = green.g;
pixel.b = blue.b;
return pixel;
}

By : Ms. Black Image Registration: ARGB Polar(radius,theta) 0 comments

Quartz Composer Patch : Introducing Ms. Black's QC Kitchen, home of VJ FOOD
/* Published by b-l-a-c-k-o-p.com
Copyright (c) 2007-2009
http://creativecommons.org/licenses/by-nc-sa/3.0/legalcode
*/

Over the holiday I had a chance to kick back and write some GLSL Kernels for our new Qamera FX. We're publishing these kernels/filters under a Creative Commons license. Non-commercial, share and share alike, with attribution. If you're a VJ and making custom patches for your own performance, feel free to use these. The non-commercial aspect really applies to inclusion in a commercial product.

Here are the kernels and the descriptions of what each does. You can find examples of their use within the .QTZ patches in Qamera. Qamera 1.x places it's Quartz Composer patches in a non-localized ~/Library/Compositions folder.

This is Ms. Black's QC Kitchen, a place where VJs can 'help themselves' to the VJ FOOD ;)

By : Ms. Black Introducing Ms. Black's QC Kitchen, home of VJ FOOD 0 comments

 

 
 
 

 B-L-A-C-K-O-P NEWS   
 SITE MAP   
 BLACKOP   
 PRESS   
 B-L-A-C-K-O-P HOME   
 DotMatrix   
 CamCamX   
 GrabberRaster   
 Q@mera   
 VirtualEyez   
 3D   
 Store   
 DOWNLOAD   
 COCOA NIBS   
 Tutorials   
 DIY Greenscreen   
 3D Webcam Mac   
 USB 3D webcam   
 BlackenedPixels   
 CatEye   
 CamCamX Blog   
 CatEye Blog   
 DotMatrix Blog   
 GrabberRaster Blog   
 Qamera Blog   
 Quicky   
 AsSceneOnTV   
 Watermarks   
 Watermarks Blog   
 PDF Watermarking Mac   
 PDFBatchBuild   
 PDF Combine Mac   
 Combine PDF Files   
 Create iTunes Booklet   
 Share Your Pictures   
 Washington DC   
 Universal Binary   
 Cocoa Programming   
 Cocoa Software   
 Screen Capture   
 Screen Grab Mac   
 iSight download   
 iSight software   
 WebCam   
 PhotoBooth download   
 iPhoto   
 Photoshop   
 MacBook Camera   
 iMac Camera   
 CamCamX compatibility   
 Fake WebCam Mac   
 VJ Software Mac   
 Video Mixer Mac   
 Live Video Switcher   
 Apple Webcam Effects   
 Webcam Video Effects   
 Free iChat Video Effects   
 Skype Video Effects Mac   
 Video Effects Stickam   
 iSight Virtualizer Mac   
 Webcast Streaming Mac   
 Best Screencast Mac   
 Desktop Streaming Mac   
 Screencast Streaming Mac   
 Broadcast Live Streaming Video Mac   
 QuickTime Broadcaster   
 Quartz Composer   
 Quartz Composer Plugins   
 Quartz Composer Patches   
 Mogulus Video FX   
 Video Effects Ustream   
 Operator11 Video FX   
 Youtube Video Effects   
 Facebook Video Effects   
 Polaroid Camera Emulator   
 No recording device found   
 Photo Booth cannot open the camera   
 Free Download/Telechargez   
 Liberi Trasferimento   
 Libere la Transferencia   
 Disclaimer   
 Corporate   
 About   
 


Copyright © 2005-2009
All Rights Reserved
B-L-A-C-K-O-P