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

AGAL Reaction Diffusion Explorer with Parameter Gradients

$
0
0
[There was a bug in the first release of this. More info here!]


A quick update to last week's AGAL and Stage3D Reaction Diffusion Explorer: I've extended the AGAL code to accept a texture that defines each of the parameters at any point in space and extended the user interface so that each parameter now has two value sliders and a toggle button bar to select a gradient type:



The bitmap data I create for the parameter gradients is much smaller that the output and scaled up to achieve 1:1 mapping. Occasionally square artefacts are visible that reflect that. I implemented a smaller parameter gradient source to improve performance, but if you want to eliminate the artifacts (before I add a control to the user interface), the variable that controls that scaling is paramsScale in the GrayScottRenderer class.

Of course, I could have avoided using bitmaps for defining values and done the work with some simple calculations. However, what bitmaps do offer is a simple way of using other types of source for varying paramters such as Perlin Noise, photograph or even other Reaction Diffusion models.

The one AGAL gotcha is that textures have to be used otherwise the render fails. So, for my second color transform pass, I setTextureAt(1, null) - took a little hair pulling to figure that out!

The new application lives here and the source code (still a dog's dinner!) lives here.

Viewing all articles
Browse latest Browse all 257

Trending Articles