Chaotic Particles using OpenCL

Posted on July 14th, 2010 in Strange Attractors, Tech Notes. 2 Comments.

screen-capture-1

First, a big thank you to Memo Akten for writing an OpenCL C++ wrapper for OpenFrameworks and providing a great million particle demo (see http://vimeo.com/7332496). You are looking at one of my modifications, where the mouse position becomes input to two parameters of a two dimensional chaotic dynamical system (a strange attractor). A serendipitous coding accident created some really intriguing effects.

I like to visualize strange attractors in real time, and OpenCL is a promising technology to take this to the next level, as it can utilize all processing cores available on a system, be they GPU, CPU, or a combination. As long as the algorithm can be made massively parallel. This is not too hard with the equations I’m working with… they are simple iterated functions – pop in an x and y coordinate and get a new x and y coordinate. Repeat this many times, and the strange attractor appears. Although most people are used to having one thread perform this iteration, there’s really no reason that a million threads can be performing it. As long as the starting positions of the particles are randomized, you’ll still get the strange attractor.

Almost. There’s an interesting numerical side-effect… when the attractor goes into a less chaotic orbit, and then comes back out to a more chaotic orbit, everything is “sparkly”; i.e. the points in the attractor are not well distributed. Because they all started from a fixed set of points (not theoretically but in practice, as they are floats), they zip around to a fixed set of points in the attractor. Or something like that.

Anyway, I attempted to overcome that with some added randomness. In the process, I have come across two really cool “accidents”, of which this is one (I love accidents in code). Basically, I’m adding a bit of random jitter to each particle. But the random value range I first tried was big enough to create this amazing motion. WOW.

Memo’s demo on Vimeo
Memo’s post on his website with more info

2 thoughts on “Chaotic Particles using OpenCL

On March 24, 2012 at 2:10 pm, jeff said:

Very interesting! The million particle demo code seems to be offline now. Do you have a mirror link to this or other similar code? thanks!

Reply

On March 26, 2012 at 10:14 pm, nathan said:

Hi Jeff, I’ve updated the link to the demo code on Memo’s site. Thanks for letting me know it was broken, and have fun experimenting! Here it is for reference: http://www.memo.tv/opencl-in-openframeworks-example-1-milion-particles-100-200fps/

Reply

Leave a Reply

Your email address will not be published. Required fields are marked *