Archive for October 14th, 2009

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:




Twitter

Error: Twitter did not respond. Please wait a few minutes and refresh this page.

October 2009
M T W T F S S
« Sep   Nov »
 1234
567891011
12131415161718
19202122232425
262728293031  

Links

Blog Stats

  • 465,901 hits