Author Archive for toneburst

19
Nov
09

The 27 Permutions Of The RGB Channels

Sometimes it’s nice to do something really simple.

Core Image Filter Kernels:

/*
	The 27 permutations of the RGB channels.

	toneburst 2009

http://machinesdontcare.wordpress.com

*/

kernel vec4 RRR(sampler image) { return sample(image, samplerCoord(image)).rrra; }
kernel vec4 RRG(sampler image) { return sample(image, samplerCoord(image)).rrga; }
kernel vec4 RRB(sampler image) { return sample(image, samplerCoord(image)).rrba; }
kernel vec4 RGG(sampler image) { return sample(image, samplerCoord(image)).rgga; }
kernel vec4 RGB(sampler image) { return sample(image, samplerCoord(image)).rgba; }
kernel vec4 RGR(sampler image) { return sample(image, samplerCoord(image)).rgra; }
kernel vec4 RBR(sampler image) { return sample(image, samplerCoord(image)).rbra; }
kernel vec4 RBG(sampler image) { return sample(image, samplerCoord(image)).rbga; }
kernel vec4 RBB(sampler image) { return sample(image, samplerCoord(image)).rbba; }

kernel vec4 GRR(sampler image) { return sample(image, samplerCoord(image)).grra; }
kernel vec4 GRG(sampler image) { return sample(image, samplerCoord(image)).grga; }
kernel vec4 GRB(sampler image) { return sample(image, samplerCoord(image)).grba; }
kernel vec4 GGR(sampler image) { return sample(image, samplerCoord(image)).ggra; }
kernel vec4 GGG(sampler image) { return sample(image, samplerCoord(image)).ggga; }
kernel vec4 GGB(sampler image) { return sample(image, samplerCoord(image)).ggba; }
kernel vec4 GBR(sampler image) { return sample(image, samplerCoord(image)).gbra; }
kernel vec4 GBG(sampler image) { return sample(image, samplerCoord(image)).gbga; }
kernel vec4 GBB(sampler image) { return sample(image, samplerCoord(image)).gbba; }

kernel vec4 BRR(sampler image) { return sample(image, samplerCoord(image)).brra; }
kernel vec4 BRG(sampler image) { return sample(image, samplerCoord(image)).brga; }
kernel vec4 BRB(sampler image) { return sample(image, samplerCoord(image)).brba; }
kernel vec4 BGR(sampler image) { return sample(image, samplerCoord(image)).bgra; }
kernel vec4 BGG(sampler image) { return sample(image, samplerCoord(image)).bgga; }
kernel vec4 BGB(sampler image) { return sample(image, samplerCoord(image)).bgba; }
kernel vec4 BBR(sampler image) { return sample(image, samplerCoord(image)).bbra; }
kernel vec4 BBG(sampler image) { return sample(image, samplerCoord(image)).bbga; }
kernel vec4 BBB(sampler image) { return sample(image, samplerCoord(image)).bbba; }

Filter Function javascript:

/*
	The 27 permutations of the RGB channels.

	toneburst 2009

http://machinesdontcare.wordpress.com

*/

function __image main(__image Image, __index Permutation) {

	switch(Permutation) {
		case  0: return RRR.apply(Image.definition, null, Image); break;
		case  1: return RRG.apply(Image.definition, null, Image); break;
		case  2: return RRB.apply(Image.definition, null, Image); break;
		case  3: return RGG.apply(Image.definition, null, Image); break;
		case  4: return RGB.apply(Image.definition, null, Image); break;
		case  5: return RGR.apply(Image.definition, null, Image); break;
		case  6: return RBR.apply(Image.definition, null, Image); break;
		case  7: return RBG.apply(Image.definition, null, Image); break;
		case  8: return RBB.apply(Image.definition, null, Image); break;

		case  9: return GRR.apply(Image.definition, null, Image); break;
		case 10: return GRG.apply(Image.definition, null, Image); break;
		case 11: return GRB.apply(Image.definition, null, Image); break;
		case 12: return GGR.apply(Image.definition, null, Image); break;
		case 13: return GGG.apply(Image.definition, null, Image); break;
		case 14: return GGB.apply(Image.definition, null, Image); break;
		case 15: return GBR.apply(Image.definition, null, Image); break;
		case 16: return GBG.apply(Image.definition, null, Image); break;
		case 17: return GBB.apply(Image.definition, null, Image); break;

		case 18: return BRR.apply(Image.definition, null, Image); break;
		case 19: return BRG.apply(Image.definition, null, Image); break;
		case 20: return BRB.apply(Image.definition, null, Image); break;
		case 21: return BGR.apply(Image.definition, null, Image); break;
		case 22: return BGG.apply(Image.definition, null, Image); break;
		case 23: return BGB.apply(Image.definition, null, Image); break;
		case 24: return BBR.apply(Image.definition, null, Image); break;
		case 25: return BBG.apply(Image.definition, null, Image); break;
		case 26: return BBB.apply(Image.definition, null, Image); break;
	}
}
18
Nov
09

Time Cube Experiments

Quick grabs. Explanation to follow.



17
Nov
09

The Original And Best…

Just by way of illustrating how far my R-E emulation has to go to match the real thing:

See if you can spot which bits are genuine analogue Scan-Processor, and which are later digital additions.

Thanks so much to Brian O’Reilly for sharing this stuff. I’m hoping we’re going to see more from the archives soon.

16
Nov
09

OpenCL Sort-Of Rutt-Etra

OK, this one needs some explanation. I know it looks almost exactly like vade’s Rutt-Etra plugin, but this one takes a slightly different approach. It’s essentially a slightly reworked version of the Apple OpenCL Text Extrusion example QTZ. I thought I’d try messing around with putting the resulting mesh inside a Kineme Polygon Mode patch (from GL Tools). I initially tried setting it to render only the raw vertices as points. You can see what that looked like in the video in the previous post.

Then, I thought I’d try rendering the mesh in Wireframe mode. Initially, there was a problem with long lines connecting the end of each row to the beginning of the next. I fixed this by stealing vade’s trick of reversing the direction of the vertices of each line. I then had to compensate for this by reversing every other line of the original input image. I actually did this with a CIFilter (thanks to cwright for showing me the error of my ways with the GLSL mod() function), though I’m sure it could be done also in the OpenCL kernel.

This later version has Point and Line modes, colour and monochrome, and some other bits and options.

13
Nov
09

OpenCL Sort-Of Particles

12
Nov
09

Time Grid

AN intermediate form, soon to evolve into something more interesting, time-permitting.

15
Oct
09

Same Old Stuff (but still nice)

…but this time, with proper lighting.

And a low-res quick video-grab. Sorry about the pause at the beginning. I can’t be bothered to install QuickTime 7 just so I can trim the beginning off the clip.

14
Oct
09

OpenCL Image –> Array

One of the exciting things about OpenCL is that you can take one kind of data, and treat it as if it’s another kind. For example, you can take image data, and take the colour information from each pixel of that image, and output it as an array of values (in reality, of course, an image IS in fact simply a multi-dimensional array. QC traditionally hasn’t treated it this way, however- until now).

It occurred to me earlier that I could use this fact to quickly generate a load of random 0 > 1 values in an array, by simply feeding a 1D texture made by passing the output of a CIRandomGenerator through a Crop, and outputting the values for the RGB and A channels of each pixel as a float4 (OpenCL’s equivalent of a GLSL vec4) in an array. Changing the crop position of the Crop patch would give you a new set of random values. I made a little self-contained CIFilter to generate the base 1D texture, and coded an OpenCL kernel to do the rest, adding Scale and Offset parameters for the generated numbers, and it seems to work.

I don’t know if this is in any way useful, but it occurred to me it might be a more efficient alternative to generating four random numbers inside an Iterator using the Random patch- you’d simply pass the whole array into the Iterator, and choose an item from the array/structure based on iteration index.

OpenCL_Random_Numbers

‘tb_OpenCL_Random_vec4_Array_141009.qtz’ in the Box.net widget.

14
Oct
09

OpenCL Perlin Mesh Noise 2D

The normals are incorrect and facetted, but I actually quite like the look.

And a quick video:

08
Oct
09

Iterated OpenCL

Done before using GLSL Shaders, but here’s the same thing with OpenCL patches inside an Iterator.

This time there’s no need to calculate normals, though, as there’s an OpenCL virtual patch to do that for me.

EDIT:

I’ve made a much more efficient version of this now. Seems marginally more crash-prone though.