Posts Tagged ‘snow

11
Mar
09

CIFilter Noise

Updated

Here’s some simple CIFilter JS to generate a random noise texture.

function __image main(__number Scale, __number _dummy)
{	
	// Create noise texture
	var randomImage = Filter.CIRandomGenerator();
	
	// Crop noise texture
	var rect = new Vec(Math.floor(Math.random() * 10000), Math.floor(Math.random() * 10000), Scale, Scale);
	randomImage = Filter.CICrop(randomImage, rect);
	
	// Call kernel function and return result
	return randomImage;
}

It’s the same as using Random and Crop patches, but all in one CIFilter patch. Like the other method, however, it creates a texture with an annoying 1-pixel black border. Not sure how to fix this issue. Also, because the CIFilter patch is only evaluated when the inputs change, you need to feed something like a Patch Time into the ‘_dummy’ input, or the image won’t change. You could probably exploit this fact to produce static noise that changed on a trigger event.

Like the constant color technique in the previous post, I don’t know if this is going to be genuinely useful to anyone. I’ll probably use it myself, if only to keep patch-cord spaghetti at bay.

Note also that the JS code doesn’t actually apply a filter kernel, but you need to have a working kernel function in the top pane of the CIFilter patch.

Advertisements



Twitter

January 2018
M T W T F S S
« Aug    
1234567
891011121314
15161718192021
22232425262728
293031  

Links

Blog Stats

  • 477,440 hits