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...

PreviewAttachmentSize
Gray-Scott.qtz104.94 KB

gtoledo3's picture
Re: Gray-Scott Diffusion Reaction in OpenCL

I haven't checked out all of the modes, but I thought this was very cool.

It does seem to perform slower than GLSL based Reaction Diffusion for some reason. I noticed that the OpenCL kernel itself is being iterated, but hadn't checked out exactly how it was all working.

I would think it would be possible to do it in OpenCL without the iteration... but does that somehow make a higher quality result?

Good work!

cybero's picture
Re: Gray-Scott Diffusion Reaction in OpenCL

Without iterations. Using very slow speed. Seems a more variegated , detailed result. What do you think? GLSL reaction diffusion still faster than this kernel. Command line OpenCL, that's a different fps and quality of output altogether. Postscript: After further testing,actually depends upon the GLSL deployed, some are faster , some are slower. Generally faster

PreviewAttachmentSize
GrayScott0.png
GrayScott0.png1.56 MB

zanroversi's picture
Re: Gray-Scott Diffusion Reaction in OpenCL

Hi, OpenCL kernel is iterated to speed up the system. With 10/20 computations per frame, the speed seems satisfying to me. It is by studying 2DFluidSimuation that I decided to iterate (as "Jacobi" operation is iterated the same way). I had to do the same in my javascript version. I saw the your GLSL implementation (and the Cinder's one too) which are great, I'll study that asap !

Also I tried quite naively to embed this composition in a Cocoa/Objective-C application (QCView). The composition is properly loaded and active except the OpenCL part.

Do you have any clue why OpenCL is not working in this way of doing, any advice to make it work ? Thanks !