11
Mar
09

Generating Base texture Inside CIFilter

Here’s a little JavaScript code-snippet to generate a base texture to pass to a CoreImage Kernel function, as a base for 2D pattern effects, for example:

function __image main(__vec2 TexSize, __color BaseColor)
{	
	// Create color-block
	var colorBlock = Filter.CIConstantColorGenerator(BaseColor);
	
	// Crop color-block
	var rect = new Vec(0, 0, TexSize.x, TexSize.y);
	colorBlock = Filter.CICrop(colorBlock, rect);
	
	// Call kernel function and return result
	return myKernelFunction.apply(colorBlock.definition, null, colorBlock);
}

Inputs allow texture-size and base colour to be set.

I like the fact that it allows for the creation of a self-contained pattern-generating CIFilter patch. I used the technique with the Plasmoids QTZ.

Advertisements

0 Responses to “Generating Base texture Inside CIFilter”



  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

March 2009
M T W T F S S
« Jan   Apr »
 1
2345678
9101112131415
16171819202122
23242526272829
3031  

Links

Blog Stats

  • 468,884 hits

%d bloggers like this: