openCL

Gray-Scott Diffusion Reaction in OpenCL

zanroversi's picture

Hi there !

It's been a long time... I would like to share a fresh composition, as an exercise with OpenCL. It's a (another...) simulation of Gray-Scott diffusion reaction system which exhibits generation of interesting patterns and structures. You may play with parameters f, k, ra, rb but the MODE index splitter will give some interesting combinations.

I learned the most I know on this subject from there : https://mrob.com/pub/comp/xmorphia/. Many thanks to the author ! he wrote a very powerful simulator too : https://mrob.com/pub/comp/xmorphia/ogl/index.html

As a beginner with OpenCL, I would be interested if any obvious improvement is possible.

Thanks for trying, have fun !

PS : I wrote firstly a Javascript / canvas based simulator, you can compare performances... : http://bunex-industries.com/blog/8d8c9c78e6e86baf084f8a573e005d61/struct...

OpenCL Heightfield Coloriser

PeMo's picture

For any OpenCL geniuses out there:

I'm attempting to colourise a vertex mesh generated in OpenCL from an input image (in fact a movie) that contains only greyscale pixels. The greyscale values drive the height (Y) of a given vertex from the XZ plane of the mesh (or whatever appropriate axes are, depending on your perspective.)

This seems to bel working fine, but I am completely stumped - as an OpenCL ignoramus - as to how I might go about creating an artificial colour ramp parametrically driven by the height of a vertex from the XZ plane (where the rest of the vertices are). A simple rainbow ramp would do.

Normally I'd attempt this using standard QC patches, but as this is running in OpenCL it seems sensible to keep it all within the kernel & hopefully running fast :)

Here's the code:


__kernel void imageRead(__rd image2d_t srcimg, const float2 size, __global float4 *vertices, __global float4 *colors, __global float4 *colorHeight) { int2 pos = make_int2(get_global_id(0), get_global_id(1)), resolution = make_int2(get_global_size(0), get_global_size(1)); int index = mad24(pos.y, resolution.x, pos.x); // faster than: pos.y * resolution.x + pos.x; float4 color; float x, y, z, r, g, b, a; sampler_t smp = CLK_ADDRESS_CLAMP_TO_EDGE | CLK_FILTER_NEAREST;

color = read_imagef(srcimg, smp, pos);

//define output colors - greyscale based on greyscale source colors[index] = color;

x = (float)pos.x/resolution.xsize.x-size.x/2; y = size.y-(float)pos.y/resolution.ysize.y-size.y/2; z = length(color.xyzw)*0.5 -.0; vertices[index] = make_float4(x, y, z, 1.);

//define output colors - height field //something I've just stuck in to see if it kinda works // putput = r,g,b,a r = z; g = z; b = z; a = 1; colorHeight[index] = make_float4(r, g , b, a);

}


I pinched this from this example http://kineme.net/composition/dust/parallelpainting.

I've attached example QC comp to demonstrate what I'm ~trying~ to do (so far with no luck - but learning lots about OpenCL in the process).

Anyway, if someone with more experience than I can have a look & make a suggestion then that would be great :) Thanks in advance.

OpenClooVision Project Volume One (Composition by cybero)

Author: cybero
License: (Other — see description)
Date: 2013.08.23
Compatibility: 10.6, 10.7, 10.8
Categories:
Required plugins:
(none)

Porting of OpenCL 1.0 computable image filter and operation kernels from the OpenClooVision project into Quartz Composer.

Darktable OpenCL Project - Volume Three (Composition by cybero)

Author: cybero
License: (Other — see description)
Date: 2013.08.21
Compatibility: 10.6, 10.7, 10.8
Categories:
Required plugins:
(none)

OpenCL Image Filters ported over from the Darktable source code kernels and header files into Quartz Composer.

Composition published under Free Document Licence http://cybero.co.uk/fdl.pdf.

Code redistributed under the GPL issued by its original author, Johannes Hanika in 2010.

Original Code Repository and Application site - http://darktable.org/

Filters are :-

graduatedndp
relight
vibrance
splittoning
vignette
colorcontrast
graduatedndm
colorize

Darktable OpenCL Project - Volume Two (Composition by cybero)

Author: cybero
License: (Other — see description)
Date: 2013.08.21
Compatibility: 10.6, 10.7, 10.8
Categories:
Required plugins:
(none)

OpenCL Image Filters ported over from the Darktable source code kernels and header files into Quartz Composer.

Composition published under Free Document Licence http://cybero.co.uk/fdl.pdf.

Code redistributed under the GPL issued by its original author, Johannes Hanika in 2010.

Original Code Repository and Application site - http://darktable.org/

Filters are :-

blendop_copy_alpha
blendop_Lab
pre_median
green_equilibration
blendop_RAW
blendop_rgb
denoiseprofile_precondition
denoiseprofile_synthesize
denoiseprofile_backtransform