Julia Set with NVIDIA Cg Fragment Shader

An animated Julia Set plot implemented as a fragment shader.

Description: I came across the book Fractals Everywhere by Michael Barnsley. Admittedly a lot of this material was over my head but it did help understanding what a fractal was and peeked my interest. With some assist from sample code found on the internet, I created a pretty basic OpenGL program that could plot the Julia Set and manipulate it's parameters.

However, this basic version was taking close to a second to generate the picture and display it. I wanted to setup some way to create animations. It occurred to me a pixel shader might be perfect for this type of application. You could generate the fractal using the GPU and the entire process would take place on the graphics card. This is the first shader I have ever made and I must say the process was much easier than I first imagined. The results blew me away. Though you need a high-end card to support the shader (the loop cannot be unrolled), I got amazing performance on my system. The animations were smooth and you could control everything in real-time using the keyboard.

There are several things I would still like to do with this program. It would be relatively easy to add support for loading and saving animations. It would also be easy to add multi-texturing and let the shader display a background texture that could be transformed and possibly blended with the fractal. It would also be possible to add random ranges that the parameters can run through making it more like a screen saver. I would also like to try mapping the texture to some primitives like a cube or sphere. This could add another dimension to the look.

Tools: Visual C++ Pro, OpenGL, NVIDIA Cg Toolkit.

Topics: OpenGL graphics, texturing, fragment shaders, fractals.

Here is a screen shot of the original OpenGL implementation.

Julia Set Image 1

Here is a another screen shot with the fractal parameters showing.

Julia Set Image 2

Here are a bunch of videos that showcase the raw power of the fragment shader. These videos were recorded by fraps in real-time @ 1280 x 1024 original resolution on my system. The videos were reduced to 800 x 600 and compressed for publication.







Please contact me if you are interested in acquiring a copy of the program, seeing the source code, or have any comments.

Back to the projects page.