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