It took a lot longer than I wanted, but the new Visions Of Chaos for Android v1.0 is now available for download. It is 100% free and ad free.

The main new feature is support for running OpenGL ES shaders on your Android device. There are over 1000 sample shaders included with the app.

So, if you own one of the 85% market share Android devices download the app from the Visions Of Chaos for Android web page or directly from Google Play now.

Smoothed-Particle Hydrodynamics (SPH) is a method of simulating fluid flow. It is based on representing a fluid by a large number of discreet (individual) particles. Each particle has properties like position, pressure, density, mass, etc. The particles are fed through a bunch of equations that make them move in a fluid like flow.

Multiphase SPH is when you have 2 or more fluids with different densities etc (think oil and water) that flow around each other and clump together.

I have always had a fascination with simulating fluids. Over the years I have tried to understand SPH and have had many failed attempts at writing programs to do it (the basic formulas seem relatively simple, but getting the code to run stable without explosions and crashes is far from simple). Then I found this blog post by Tom Madams that had sample source code. With that I was finally able to get SPH working. It can still be fiddly to find a nice set of parameters to make a nice looking movie, but Tom’s code seems to be a great start. Thanks Tom!!

If you are a nerd then you most likely have heard of Karl Sims. If you haven’t heard of him give his page a browse as there is some good stuff there.

I have admired and respected him since his work in Genetic Images back in 1993 that inspired all three of my attempts at Genetic Art so far. I still have a few more ideas on new Genetic Art methods to experiment with and share when I get some spare time.

I noticed his latest work as I was browsing Reaction Diffusion videos on YouTube. Yes, if you know what to look for there are videos on YouTube better than this one that was featured on their homepage and has millions of hits so far. I must be getting old(er)… “What is wrong with kids these days”!?

Check these two RD samples Karl put up on YouTube.

The most impressive aspect of those is the shading that gives them the 3D look. (Aussies can confirm the almost exact reflectance of the second example to Vegemite). Remember that the output of these Reaction Diffusion equations is strictly 2D. The bulging 3D look is based on calculating the slope between neighbouring pixels. Or at least that is how I do it in Visions Of Chaos, but Karl’s versions seem so much more 3Dish than mine. See his images here that are awesome.

As always he inspires me (and I am sure many others) to do better.

I have been interested in video feedback and simulating video feedback on and off for years.

I recently stumbled across this amazing 4k demo. The exe file that generates the following movie in realtime is less than 4096 bytes in size!!

Awesome result. The makers kindly wrote up an explanation page that describes how the video feedback like effects were created.

So based on those principals I used a bunch of (slower) non shader software based image processing routines and got the following results.

These are much faster to generate than my previous experiments with simulating video feeback.

Generation Steps

Initialisation
1. Create 2 bitmaps for a main layer and a temp layer
2. Fill them both with random static

Main loop
1. Each pixel RGB in the main bitmap is converted to HSL. The HSL values are used as an angle and a distance. The angle and distance then points to a new pixel location on the temp bitmap. The main bitmap pixel is the colored using the temp bitmap pixel color.
2. Sharpen the main bitmap.
3. Blur the main bitmap.
4. Display the main bitmap.
5. Blend the main bitmap with the temp bitmap.
6. Rotate the temp bitmap.
7. Histogram equalise the temp bitmap. This is similar to how Photoshop does auto-contrast.
8. Zoom the temp bitmap.

Here is a full 1080p HD sample with 10 minutes of footage showing the types of results this new algorithm creates.

If you are not a coder and want to play with this download Visions Of Chaos.

Ahhh, Spirograph, that simple set of plastic cogged discs and rings that created a huge amount of spirally patterned goodness (as long as you kept a steady hand and didn’t jump a cog tooth). I still remember how cool they were prior to the home computer age. Here is a 1973 commercial for them.

And here is a commercial from the 80s.

Visions Of Chaos currently supports rendering 2D spirographs, but I have wanted to explore a 3D extension of Spirographs for a long time.

It was surprisingly difficult to find the formulas required to plot the 3D result of spheres rotating within spheres within speheres etc. Finally, thanks to Henry de Valence’s code I was able to add 3D Spirographs to Visions Of Chaos.

OpenProcessing is a goldmine of ideas/formulas/algorithms. Anyone who enjoys computer graphics and programming needs to check it out.

Here are two early sample movies resulting from my initial test code.

Once they showed potential I made sure that Visions Of Chaos supported the true 1080p “real side by side 3d” output and got the following result. This looks amazing on my LG 3D TV with the polarised glasses. They really pop what seems at least a foot out of the screen as they rotate.

If you want to have a play with the new 3D Spirograph mode, download Visions Of Chaos.

Info For Coders

If you are a programmer who is looking to explore the incredible space of 3D Spirographs here is the main code that you will need to plot the curve in 3D space. This is a direct copy and paste from Henry’s processing code.

ax = 0; ay =0; az = 0;
bx = 0; by =0; bz = 0;
for(int i = 0; i < num_segments; ++i) {
bx = ax + r[i]*sin(f[i]*t)*cos(g[i]*t);
by = ay + r[i]*sin(f[i]*t)*sin(g[i]*t);
bz = az + r[i]*cos(g[i]*t);
line(ax, ay, az, bx, by, bz);
ax = bx; ay = by; az = bz;
}

num_segments is how many recursive spheres within spheres you use. For the above sample 3D movie most of them used 2 spheres, but any higher number works too and will lead to much more complex and twisted plots.

r[i] are the radius lengths of each sphere or arm segment.

f[i] and g[i] are non zero +/- period values that change the resulting plot shapes. I tested and used values between -45 and +45 for my images and movies to extend the possible resulting shapes. If the values are rational (integer numbers) then the plot will eventually come back to the start point and retrace itself.

t is time that starts at 0 and should be changed 0.01 or so per update for a smooth plot.

the ax to bx etc swapping keeps track on the sphere within sphere.

Once the segment loop is finished bx,by and bz are the next 3D point in space the Spirograph is at.

At this stage you should be plotting nice 3D spirographs. One very helpful tip is how to work out when to stop calculating and plotting new points. As stated above if you use integer values for the periods then the plot will always return to the start position and beging retracing itself again. Being able to pre-calculate how many steps the plot needs is a handy feature to have.

To calculate the ideal value that the time t variable will be when the plot finishes you find the least common multiplier (LCM) of all the period values. eg if you have a spirograph using 3 arms/segments you will need to calculcate the LCM of 6 period values. Chances are your programming language of choice has a LCM(a,b) function that takes two values. For 3 or more values you recursively call the LCM function. ie the LCM of a,b and c is LCM(a,LCM(b,c)). Thanks again to Henry for the LCM tip.

See this post for the original Multi-Scale Turing Patterns that came before these variations.

This post was inspired by a comment from Jonathan McCabe on one of his pictures here. What happens when you add a fluid simulator on top of Multi-Scale Turing Patterns?

I already had a simple 2D fluid simulation in Visions Of Chaos based on Jos Stam’spaper and accompanying source code so after some hacking I managed to incorporate it into each step of the Multi-Scale Turing Patterns steps.

Here is a sample movie using the standard Multi-Scale Turing Patterns method.

And here is the same initial start and parameters but this time including Stam’s stable fluid code at each step. This gives more whispy, hairy and vein like features. It also seems to break the cyclic repetitve nature the turing method alone can lead to. Maybe I like the change, maybe not.

And finally another sample. This time with slightly more agressive fluid, histogram equalization auto-contrast (as the above sample was a bit too grey and washed out for my liking) and a pseudo 3D effect.

I then tried using Perlin Noise as a displacement map to push the grid around.

This sample movie is only using a Perlin Noise displacement map.

This sample uses Perlin Noise and then Stam’s Fluid.

This sample uses Stam’s Fluid and then Perlin Noise.

All of the above six movies were created with the latest version of Visions Of Chaos.

Jonathan still continues to amaze me and recently showed off his latest works like this stunning image.

Click for a full size view.

I hope he shares some of the secrets behind that one. I would love to have a play around with it and add something similar to Visions Of Chaos.