Fractals, Cellular Automata, Chaos Theory, Science, Space, etc

Category Archives: GLSL

One of the features I have wanted to implement since the earliest versions of Visions of Chaos has been a formula editor and compiler so users can experiment with their own fractal formulas. This has also been requested many times from various users over the years. Now it is finally possible.

Rather than write my own formula parser and compiler I am using the OpenGL Shading Language. GLSL gvies faster results than any compiler I could code by hand and has an existing well documented syntax. The editor is a full color syntax editor with error highlighting.

As long as your graphics card GPU and drivers support OpenGL v4 and above you are good to go. Make sure that you have your video card drivers up to date. Old drivers can lead to poor performance and/or lack of support for new OpenGL features. In the past I have had outdated drivers produce corrupted display outputs and even hang the PC running GLSL shader code. Always make sure your video drivers are up to date.

So far I have included the following fractal formulas with the new Visions of Chaos. All of these sample images can be clicked to open full 4K resolution images.

Buffalo Fractal Power 2

Buffalo Fractal Power 3

Buffalo Fractal Power 4

Buffalo Fractal Power 5

Burning Ship Fractal Power 2

Burning Ship Fractal Power 3

Burning Ship Fractal Power 4

Burning Ship Fractal Power 5

Celtic Buffalo Fractal Power 4 Mandelbar

Celtic Buffalo Fractal Power 5 Mandelbar

Celtic Burning Ship Fractal Power 4

Celtic Mandelbar Fractal Power 2

Celtic Mandelbrot Fractal Power 2

Celtic Heart Mandelbrot Fractal Power 2

Heart Mandelbrot Fractal Power 2

Lyapunov Fractals

Magnetic Pendulum

Mandelbar (Tricorn) Fractal Power 2

Mandelbar Fractal Power 3

Mandelbar Fractal Power 3 Diagonal

Mandelbar Fractal Power 4

Mandelbar Fractal Power 5 Horizontal

Mandelbar Fractal Power 5 Vertical

Mandelbrot Fractal Power 2

Mandelbrot Fractal Power 3

Mandelbrot Fractal Power 4

Mandelbrot Fractal Power 5

Partial Buffalo Fractal Power 3 Imaginary

Partial Buffalo Fractal Power 3 Real Celtic

Partial Buffalo Fractal Power 4 Imaginary

Partial Burning Ship Fractal Power 3 Imageinary

Partial Burning Ship Fractal Power 3 Real

Partial Burning Ship Fractal Power 4 Imageinary

Partial Burning Ship Fractal Power 4 Real

Partial Burning Ship Fractal Power 5

Partial Burning Ship Fractal Power 5 Mandelbar

Partial Celtic Buffalo Fractal Power 4 Real

Partial Celtic Buffalo Fractal Power 5

Partial Celtic Burning Ship Fractal Power 4 Imaginary

Partial Celtic Burning Ship Fractal Power 4 Real

Partial Celtic Burning Ship Fractal Power 4 Real Mandelbar

Perpendicular Buffalo Fractal Power 2

Perpendicular Burning Ship Fractal Power 2

Perpendicular Celtic Mandelbar Fractal Power 2

Perpendicular Mandelbrot Fractal Power 2

Quasi Burning Ship Fractal Power 3

Quasi Burning Ship Fractal Power 5 Hybrid

Quasi Celtic Heart Mandelbrot Fractal Power 4 Real

Quasi Celtic Heart Mandelbrot Fractal Power 4 False

Quasi Celtic Perpendicular Mandelbrot Fractal Power 4 False

Quasi Celtic Perpendicular Mandelbrot Fractal Power 4 Real

Quasi Heart Mandelbrot Fractal Power 3

Quasi Heart Mandelbrot Fractal Power 4 Real

Quasi Heart Mandelbrot Fractal Power 4 False

Quasi Heart Mandelbrot Fractal Power 5

Quasi Perpendicular Burning Ship Fractal Power 3

Quasi Perpendicular Burning Ship Fractal Power 4 Real

Quasi Perpendicular Celtic Heart Mandelbrot Fractal Power 4 Imaginary

Quasi Perpendicular Heart Mandelbrot Fractal Power 4 Imaginary

Quasi Perpendicular Mandelbrot Fractal Power 4 False

Quasi Perpendicular Mandelbrot Fractal Power 5

A lot of the above formulas came from these summaries stardust4ever created.

All of these new custom fractals are fully zoomable to the limit of double precision floating point variables (around 1,000,000,000,000 magnification in Visions of Chaos). The formula compiler is fully supported for movie scripts so you can make your own movies zooming into these new fractals.

This next sample movie is 4K resolution at 60 fps. Each pixel was supersampled as the average of 4 subpixels. This took only a few hours to render. The resulting Xvid AVI was 30 GB before uploading to YouTube.

So, if you have been waiting to program your own fractal formulas in Visions of Chaos you now can. I look forward to seeing the custom fractal formulas Visions of Chaos users create. If you do not understand the OpenGL shading language you can still have fun with all the default sample fractal formulas above without doing any coding.

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 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.

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. GLSL supports single precision floating point numbers so deep zooms into the bulb will be less defined, but for the majority of renders you won’t notice a difference.

For example, here is a relatively deep zoom into a Mandelbulb using the CPU double precision

and here is the same with single point GPU/GLSL single precision

Single precision GLSL has the approximate floating point limit/resolution of 0.000001 which Visions Of Chaos now clamps the epsilon value to if it ever gets beyond it and you are using the GLSL calculations. No doubt NVidia and ATI will get the double precision working in future models, but for the time being if you want to do deep zooms into Mandelbulbs and related fractals you will hit the precision wall.

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.

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.

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.

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!”.

I have been interested in Wada Basins for some time now. Wada Basins are the fractal like patterns that occur between touching reflective spheres. I finally got around to start adding support for GLSL into Visions Of Chaos. GLSL is the OpenGL Shading Language that allows you to use your graphics card processor (GPU) to do calculations that are magnitudes times faster than your CPU will ever be able to accomplish.

Here is a sample zoom sequence into a wada basin rendered using path tracing. Using the path tracing approach leads to global illumination with colors bleeding into nearby surfaces and soft shadows. If I was to even attempt to render these sort of images on the CPU alone this post would be months away, but harnessing the power of the GPU allowed these snapshots to be done in relatively no time at all.

The new version of Visions Of Chaos supporting GLSL will be out soon “when it’s ready”. I have meant to release it for a while now, but I keep adding new features and making changes.