Quantcast
Channel: FlexMonkey
Viewing all articles
Browse latest Browse all 257

ReDiLab: Node - Coupled Reaction Diffusion Systems with a Node Based User Interface

$
0
0

Towards the end of last year, I spent a lot of time experimenting with coupled reaction diffusion models. These resulted in some great outputs, but each one was painstakingly hand coded and any changes to the coupling method or reaction diffusion models required a new application.

I've been playing with node based interfaces for almost as longs as I've been coding Flex and the Christmas break gave me some free time to begin coding ReDiLab: Node: my node based evolution of ReDiLab. This Apache Flex application displays a node for each reaction diffusion model with inputs and outputs that define the coupling between each model.

I had two false starts. I originally assumed that I could create endless Stage3D instances from stage.stage3Ds[ ] and assign one to each node - but, sadly, I could only create four and even that slowed everything down to a near halt. 

My second version used the venerable Pixel Bender. Pixel Bender initially seemed like a fantastic solution: a higher level language than AGAL and Pixel Bender shaders can be applied to display objects, so no worries about bits of the UI (e.g. the coupling relationship curves) overlapping the output.

Sadly, it seems that Adobe, in their infinite wisdom, have quietly deprecated Pixel Bender.

My third attempt was to return to Stage3D. I've ended up creating individual renderers for each reaction diffusion model which execute their own individual programs. Each frame, every node may run several iterations before finally setting their own output - for ingestion by their siblings - and drawing their result to a bitmapData instance.

This use of drawToBitmapData() isn't ideal. It's quite slow to readback from the GPU to the CPU, so I've done two things to mitigate this: one is to keep the simulation size quite small (256 * 256 pixels) and the other is to offer the user an option to turn off the preview by double clicking the node. 

The end result is actually quite nippy. Here's a real time recording of a run through of the application on my iMac:




The model I used is Gray Scott with the AGAL code taken from my ReDiLab application. I've changed the Laplacian function from a five point to a standard nine point. The node based user interface code originates from experiments with Parsley I did back in 2010.

I've spent some time creating presets for individual models. These can be applied to just the low values (i.e. where an input model's v is low) or just the high (i.e. where an input model's v is high) of a parameter. The interesting results happen when there's a contrast between the two: for example dense spots for low and big blobs for high.

There are also lots of scene presets. These demonstrate a variety of different networks with some interesting, often quite biological looking, results. Nodes can be recursive, so they can be autocatalytic (their own output feeds into their input) or mutually catalytic (their output feeds into another's input which, in turn, feeds back into their input)

The next steps are to integrate other reaction diffusion models such as FizHugh Nagumo and Ginzburg Landau and to add alternate coupling methods such as cubic coupling.



Viewing all articles
Browse latest Browse all 257

Trending Articles