GLSL support added to Visions Of Chaos

What is GLSL?

The OpenGL Shading Language (or GLSL) allows you to write programs that run on the GPU rather than the CPU. GPUs these days can have thousands of “cores” so code running on the GPU can be magnitudes faster than running on the CPU. Fractal images are ideal for GLSL because in most fractals each pixel can be calculated independantly of the others so it is ideal for running in parallel.

For example the following pic is a raytraced example of five touching reflective spheres. The CPU version of this code took minutes to render. The GPU shader code takes 65 milliseconds on a not so super Nvidia card.

GLSL Wada Basins

GLSL in Visions Of Chaos

After having been on my to do list for years, I have finally gotten around to adding GLSL support into Visions Of Chaos.

Mandelbulb

The main delay in releasing this new version was converting all the Mandelbulb mode related functions into the GLSL language. Not too difficult, but very tedious. The speed increase for the Mandelbulb mode is amazing.

The output quality is mostly identical to the non-GLSL software mode rendering, so all your existing sample Mandelbulb files will usually continue to load and display as normal.

Mandelbox

I will be converting more of the slower modes over to GLSL in the future. Mandelbulbs had to be first as that was the most complex and hence slowest mode in Visions Of Chaos.

Mandelbulb

These are some speed increase results after testing the new Mandelbulb shader code on some different PCs (ranked from worse to best);

NVidia Geforce 9500 GT – 7 to 17 times faster.

NVidia Geforce 8500 GT – 15 to 25 times faster.

NVidia Geforce 8800 GT – 102 to 154 times faster.

NVidia Geforce GTX 570 – 140 to 230 times faster.

Make sure you have the latest drivers for your video card. Updating to the latest version can help improve perfomance.

Mandelbulb

I also included a bunch of sample shaders from the GLSL Sandbox to show off what these rather simple shaders can do on a decent (or even not so decent) graphics card.

Mandelbulb

On a side note I have the above image printed out and stuck on the wall at work in my office as it is one of my more favourite and iconic Mandelbulb images. It freaked this one guy out. “Doesn’t that give you the creeps that picture?!”. I tried to explain what it actually was but all he could relate it to was Alien. “Well it is actually based on a relatively simple mathematical formula that makes all those complex self similar patterns”. His eyes glazed over before I dared mention complex numbers and their three dimensional triplex variants. “Nah man, too bizarre for me!”.

Jason.

JPS Stereoscopic Fractals

I recently purchased a LG TV capable of 3D display. It comes with passive 3D glasses (ie no shutters with polarised lenses – similar to the ones you wear in the cinema when watching a 3D movie).

The first thing that came to mind was how do I get Visions Of Chaos to output images that the TV will show in “real” 3D when wearing the glasses.

Firstly I discovered the MPO format. The official MPO spec is too complicated for me to implement and doing a quick web search for source code shows nobody else has worked it out who is willing to share a snippet. Note: if you have a left and right eye image file and need to combine them into MPO format you can use Stereo Photo Maker.

Then I found the JPS format which is a much simpler 3D image format to support. JPS is simply a JPEG image file with the two eye images side by side. The right eye image on the right and the left eye image on the left. Getting Visions Of Chaos to stitch the left and right images together into a JPS was simple, so now anyone with a JPS capable device will be able to see fractals (and any 3D output) from Visions Of Chaos in real pop out of the screen 3D.

Each JPS image should be HDV 1080p resolution (1920×1080 pixels), and each of the “eye” images needs to be resized/squashed to half width.

For example, this image

Mandelbulb Fractal

becomes this image with the squished right and left eye images

JPS Stereoscopic Image

If you have a device capable of displaying JPS images, download the above image, rename the extension to JPS and view it to see in real 3D.

Here are a few other sample images. Again they need to be renamed to JPS before viewing on a device that supports the JPS format.

JPS Stereoscopic Image

JPS Stereoscopic Image

JPS Stereoscopic Image

See more in my flickr gallery.

All of these images really “pop” on my TV and have impressed even non-fractal friends who have seen them. Visions Of Chaos now supports JPS stereoscopic images along with the usual anaglyph formats (red/blue, red/cyan, wiggle gif, etc).

The next step was to support 3D movies. All the 3D outputs in Visions Of Chaos now support side by side real stereoscopic 3D output. Here is a quick sample. On a 3D device you can look deep into the fractal structure.

More samples to come.

Jason.

Even More New Mandelbulb Variations

Rule 5101 – Power 5 Juliabulb
Mandelbulb Fractal

Rule 20955 – Power 6 Mandelbulb
Mandelbulb Fractal

Hybrid Mandelbulb
Mandelbulb Fractal

After the previous encouraging results here and here I had to try the fully extended 32,768 possible permutations of these trig variations.

Theta and Phi are initialised by using

theta:=arctan2(z.y,z.x);
phi:=arcsin(z.z/radius);

The Triplex Algebra power function uses

x=radius*cos(phi)
y=radius*cos(theta)*cos(theta)
z=radius*sin(phi)*cos(phi)

Each of the trig components can be +/- sin/cos phi/theta.

Convert these 15 possible combos into a 15 digit binary number using the following rules for each digit from left to right;
1. 0 for X COS, 1 for X SIN
2. 0 for X Phi, 1 for X Theta
3. 0 for +, 1 for –
4. 0 for Y COS, 1 for Y SIN
5. 0 for Y Phi, 1 for Y Theta
6. 0 for +, 1 for –
7. 0 for 2nd Y COS, 1 for 2nd Y SIN
8. 0 for 2nd Y Phi, 1 for 2nd Y Theta
9. 0 for +, 1 for –
10. 0 for Z COS, 1 for Z SIN
11. 0 for Z Phi, 1 for Z Theta
12. 0 for +, 1 for –
13. 0 for 2nd Z COS, 1 for 2nd Z SIN
14. 0 for 2nd Z Phi, 1 for 2nd Z Theta
15. 0 for +, 1 for –

After letting my PC churn away for a few days I had the results of the 32,768 variations. Here are the 16 I found most interesting and/or unique.

Rule 420

Mandelbulb Fractal

Rule 1334

Mandelbulb Fractal

Rule 1444

Mandelbulb Fractal

Rule 2980

Mandelbulb Fractal

Rule 5101

Mandelbulb Fractal

Rule 5613

Mandelbulb Fractal

Rule 6326

Mandelbulb Fractal

Rule 8575

Mandelbulb Fractal

Rule 8703

Mandelbulb Fractal

Rule 11262

Mandelbulb Fractal

Rule 13246

Mandelbulb Fractal

Rule 16795

Mandelbulb Fractal

Rule 17290

Mandelbulb Fractal

Rule 17856

Mandelbulb Fractal

Rule 20937

Mandelbulb Fractal

Rule 20955

Mandelbulb Fractal

All of these new variations are now avilable in Visions Of Chaos.

Jason.

More new Mandelbulb Variations

Rule 181 – Power 8 Mandelbulb
Mandelbulb Fractal

Rule 388 – Power 4 Juliabulb
Mandelbulb Fractal

Rule 404 – Power 2 Juliabulb
Mandelbulb Fractal

Rule 1328 – Power 4 Juliabulb
Mandelbulb Fractal

Rule 2160 – Power 8 Juliabulb
Mandelbulb Fractal

Rule 2512 – Power 2.9 Juliabulb
Mandelbulb Fractal

After the last success with new Mandelbulb variations I extended the possible search space. These variations are also created from formulas from Tad Boniecki. Three of his variations followed these same basic forms.

See this blog post for all the details of the previous new variations. The only change here is adding a second trig call to the Y component. So now, the possible variants follow the pattern

x=radius*cos(phi)
y=radius*cos(theta)*cos(theta)
z=radius*sin(phi)

Each of the trig components can be +/- sin/cos phi/theta.

Convert these 12 possible combos into a 12 digit binary number using the following rules for each digit from left to right;
1. 0 for X COS, 1 for X SIN
2. 0 for X Phi, 1 for X Theta
3. 0 for +, 1 for –
4. 0 for Y COS, 1 for Y SIN
5. 0 for Y Phi, 1 for Y Theta
6. 0 for +, 1 for –
7. 0 for 2nd Y COS, 1 for 2nd Y SIN
8. 0 for 2nd Y Phi, 1 for 2nd Y Theta
9. 0 for +, 1 for –
10. 0 for Z COS, 1 for Z SIN
11. 0 for Z Phi, 1 for Z Theta
12. 0 for +, 1 for –

This bumps the total possible variations up to 4096. After letting the PC churn away for a few hours I had all possible variations with thumbnails (I have avoided posting all 4096 images to flickr this time).

After deleting the spikey and lathed results this got the count of possibles down to 1288.

Deleting all the assymetrical results got the count down to 266 possibles.

Then comes the difficult part. You get down to a bunch of symmetric bulbs that fall into catagories of similar shapes and styles. Culling down the least interesting out of a bunch of 10 or so very similar images sent me cross eyed. In the end I narrowed 4096 down to 27.

Rule 181

Mandelbulb Fractal

Rule 388

Mandelbulb Fractal

Rule 397

Mandelbulb Fractal

Rule 404

Mandelbulb Fractal

Rule 924

Mandelbulb Fractal

Rule 965

Mandelbulb Fractal

Rule 972

Mandelbulb Fractal

Rule 989

Mandelbulb Fractal

Rule 997

Mandelbulb Fractal

Rule 1328

Mandelbulb Fractal

Rule 1412

Mandelbulb Fractal

Rule 1575

Mandelbulb Fractal

Rule 1841

Mandelbulb Fractal

Rule 1996

Mandelbulb Fractal

Rule 2016

Mandelbulb Fractal

Rule 2017

Mandelbulb Fractal

Rule 2024

Mandelbulb Fractal

Rule 2160

Mandelbulb Fractal

Rule 2161

Mandelbulb Fractal

Rule 2512

Mandelbulb Fractal

Rule 2521

Mandelbulb Fractal

Rule 2537

Mandelbulb Fractal

Rule 2608

Mandelbulb Fractal

Rule 2619

Mandelbulb Fractal

Rule 2969

Mandelbulb Fractal

Rule 2984

Mandelbulb Fractal

Rule 3394

Mandelbulb Fractal

All of these new variations are now avilable in Visions Of Chaos.

Jason.

New Mandelbulb Variations

Rule 52 – Power 8 Mandelbulb
Mandelbulb Fractal

Rule 330 – Power 8 Mandelbulb
Mandelbulb Fractal

Rule 330 – Power 8 Mandelbulb
Mandelbulb Fractal

Tad Boniecki emailed me with some new Mandelbulb trig variations. The only changes in these from the usual method of rendering Mandelbulbs is the formula for Triplex Power. For the original Positive SIN Mandelbulb the routine looks like;

function SINTriplexPower(const z:triplex;p:double):triplex;
var rcosphi:double;
begin
radius:=power(radius,p);
theta:=theta*p;
phi:=phi*p;
SINTriplexPower.x:=radius*cos(phi)*cos(theta);
SINTriplexPower.y:=radius*cos(phi)*sin(theta);
SINTriplexPower.z:=radius*sin(phi);
end;

The new methods changed the trig values for X, Y and Z. The main change here is there is only a single trig call for each XYZ component.

function Trig1TriplexPower(const z:triplex;p:double):triplex;
begin
radius:=power(radius,p);
theta:=theta*p;
phi:=phi*p;
Trig1TriplexPower.x:=radius*cos(phi);
Trig1TriplexPower.y:=radius*cos(theta);
Trig1TriplexPower.z:=radius*sin(theta);
end;

Theta and Phi are initialised by using

theta:=arctan2(z.y,z.x);
phi:=arcsin(z.z/radius);

After randomly trying different combinations for a while, I wrote a simple loop to go through all possible combinations of these type of Mandelbulb.

For each of the XYZ components they can be in the form +/- sin/cos(phi/theta). eg -cos(phi) or sin(theta) etc. This gives a total of 512 possible combinations.

Using a Wolfram like rule numbering system, convert a nine digit binary number into decimal. The digits of the binary number correspond to;
1. 0 for X COS, 1 for X SIN
2. 0 for X Phi, 1 for X Theta
3. 0 for +, 1 for –
4. 0 for Y COS, 1 for Y SIN
5. 0 for Y Phi, 1 for Y Theta
6. 0 for +, 1 for –
7. 0 for Z COS, 1 for Z SIN
8. 0 for Z Phi, 1 for Z Theta
9. 0 for +, 1 for –
So rule number 20 is binary 000010100 and converts into the formulas
x:=radius*cos(phi);
y:=radius*cos(theta);
z:=radius*sin(phi);

You can see all 512 variations (all power 8 Mandelbulbs) here. Each of the image names show the rule number and corresponding trig calls.

From the 512 possible results, I ignored most of them (too spikey, too similar to others, too lathed, or assymetrical) and picked the 20 most interesting results.

Rule 50

Mandelbulb Fractal

Rule 52 (This is also the rule for the image at the top of this post)

Mandelbulb Fractal

Rule 53

Mandelbulb Fractal

Rule 59

Mandelbulb Fractal

Rule 61

Mandelbulb Fractal

Rule 114

Mandelbulb Fractal

Rule 116

Mandelbulb Fractal

Rule 117

Mandelbulb Fractal

Rule 124

Mandelbulb Fractal

Rule 176

Mandelbulb Fractal

Rule 177

Mandelbulb Fractal

Rule 188

Mandelbulb Fractal

Rule 280

Mandelbulb Fractal

Rule 330

Mandelbulb Fractal

Rule 369

Mandelbulb Fractal

Rule 370

Mandelbulb Fractal

Rule 377

Mandelbulb Fractal

Rule 412

Mandelbulb Fractal

Rule 413

Mandelbulb Fractal

Rule 465

Mandelbulb Fractal

All of these new variations are now avilable in Visions Of Chaos.

Tad also had a few other new variations with more trig calls I will experiment with and explain in a future post.

Jason.

Hybrid Mandelbulbs

The new version of Visions Of Chaos now supports Hybrid Mandelbulbs.

Hybrid Mandelbulb

Hybrid Mandelbulb

Hybrid Mandelbulb

The basic idea is that you alternate the Mandelbulb formula between iterations for each pixel. So for example the 1st, 3rd, 5th, etc iterations use the regular positive SIN Mandelbulb formula and the 2nd, 4th, 6th, etc iterations use the Rucker variation.

Here is a quick sample movie.

More sample images can be seen in my Hybrid Mandelbulb Gallery.

Jason.

Fog and Depth Of Field for Mandelbulbs

The new release of Visions Of Chaos now supports fog and depth of field effects for Mandelbulb, Mandelbox and Kaleidoscopic IFS modes.

Fog bleeds color away from areas of the fractal further away from the camera and depth of field blurs parts of the fractal that outside the focal point (this simulates the way a real camera takes photos with areas further away become more blurred). Using both fog and/or depth of field really help to bring out the 3D look of the fractals.

Jason.