|
|
|
|
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: alpha channel, mask
By : Ms. Black Sawtooth Mask
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: alpha channel, mask
By : Ms. Black Soft Radial Mask
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: alpha channel, mask
By : Ms. Black Soft Rectangular Mask
|
|
|
|
|
|