Dfrac – Mandelbrot Explorer

John W. Ratcliff

jratcliff@infiniplex.net

 

http://codesuppository.blogspot.com

 

Alpha Test Release – January 2, 2008

 

www.amillionpixels.us/Dfrac_1.0.exe

 

This is an alpha test release of a program I have been working on over the holidays.  I am revisiting a Mandelbrot program I wrote a number of years ago.  This one has been revised to work with DirectX and has some basic 3d graphics support.  This implementation use ‘double’ floating point numbers which limits how deeply you can dive into the Mandelbrot set.  A future release will support the ability to use near infinite resolution floating point numbers allowing you to delve as deeply as you want.  (NOTE: The checkbox to enable Multi-Threading is available on this version, but it produces some glitchy output.  Improved multi-threading support will be available on the next release.)

 

My primary goal with this program is to create the fastest interactive Mandelbrot explorer ever made.  With this alpha release it isn’t quite there yet.  I recently got a Quad-Core machine at work and ever since I did I have wanted to create a program that takes maximum advantage of all four processors using micro-threading.  Multi-Threading is enabled on this alpha release but it still has some glitches in the output and does not run as fast as I want it to.  In the next couple of years we will see more and more multi-core machines and my goal is to make Dfrac become a baseline open-source test application to visually demonstrate the benefits of this technology.

 

Programs which are almost entirely bound by computation, rather than memory, are ideally suited to showcase the power of multi-core.  Another concept I am trying to exercise is micro-threading.  This is a technique where a single individual physical thread is designed to process thousands upon thousands of ‘micro-jobs’.  The goal is to get the per-job overhead so low that you can achieve near full processor utilization even as it operates on tens of thousands of tiny tasks.  There are many computation algorithms which can be sped up using a micro-threaded design.  In a future release of Dfrac you will be able to change the job size on the fly to measure the overall processor utilization.

 

Another unique aspect of Dfrac is how it draws the Mandelbrot itself.  Most Mandelbrot exploration programs solve the equation in a sequential fashion.  Dfrac uses a different technique entirely.  It recursively subdivides the fractal into smaller and smaller rectangles.  For each rectangle it computes its complexity by taking the mean iteration count along all of the edges.  The Mandelbrot is then solved and rendered by processing the ‘easiest to compute’ regions first, leaving the most difficult (and often most boring) parts for last.   This really helps when zooming around the fractal as you can see the overall outline almost immediately.  Another important optimization is that any time a rectangle has the same iteration count along all of its edges it is accepted as a single whole piece, thereby eliminating the need to compute values for the interior.   This is based on a proof presented in Martin Gardner’s column in Scientific American many years ago.  The proof stated that if any continuous boundary in a Mandelbrot had the same value, then it was true that the interior was identical.  This can dramatically increase the speed of Mandelbrot computation, especially with very high iteration counts.

 

When you first launch Dfrac you will see the following screen.

 

 

 

By default the program will start zoomed out to the entire Mandelbrot set.  The background image is dimmed so that you can more easily read the user interface elements.  The entire user interface is toggled on and off by hitting the F1 key.  When the user interface is toggled off, the Mandelbrot will be displayed at full brightness.

 

With the user interface toggled off, the basic navigation interface for exploring the Mandelbrot is as follows:

 

·        Use the arrow keys to scroll around the image.

·        Use the keypad plus/minus keys to zoom in and out.

·        The SPACEBAR will toggle between preview only mode or not.

·        Double click with the mouse to center the image at that point.

·        Left mouse click and drag to pan the image around the screen.

·        Use the middle mouse wheel to zoom in and out.

·        Press the ‘P’ key to perform a screen capture.

·        Press the ‘M’ key to toggle between the 3d view and the 2d flat view.

 

An important optimization is enabled whenever you are panning around the image.  Instead of recalculating the entire screen, instead it will only recompute the pixels which were not previously completed.  This allows you to zoom deep into the fractal and then scroll around an area in near real-time!

 

The following interface keys apply while you are in the 3d view mode.

 

·        WASD and the arrow keys will move the camera around the 3d environment.

·        The left mouse button will allow you to rotate the camera around the scene.

·        Hitting the number keys ‘0’ through ‘9’ will increase or decrease the speed of the camera movement.

·        Holding the Shift Key down in conjunction with the arrow keys and the plus/minus key will cause the Mandelbrot to scroll and zoom even while in 3d mode.

 

 

The User Interface elements work as follows:

 

·        Default Mandelbrot       : Hitting this button will move the Mandelbrot back to the default home position.

·        Preview Only                : This checkbox will toggle between showing only the lower resolution preview mode, or both the preview and the high resolution image.

·        Use Rectangle Subdivision : If this checkbox is on, then the rectangle subdivision algorithm is used.  Otherwise the Mandelbrot is computed sequentially.

·        View3d                        : This check box controls whether the 3d view is active or not.

·        Wireframe Overlay       : If this check box is on and you have created an optimized mesh, then the optimized mesh will be rendered with a wireframe overlay.

·        Filter Fractal                 : This button will run one pass of a filter on the 3d fractal mesh.  This can smooth out the fractal and make it look more compelling in 3d.

·        Optimize Mesh : This button will take the current high resolution 3d fractal and convert it to an optimized mesh.  The optimized mesh will render much faster.

·        Color Scale                  : This slider controls who the color palette is indexed.  As you zoom deeper into the Mandelbrot you may want to lower this value to create smoother gradients.

·        Iteration Count : This slider controls how many iterations are performed on the Mandelbrot.  You may want to make this higher the deeper you zoom.

·        Cycles Per Frame         : This slider controls how much CPU is consumed each frame.  If you lower this value, the application will be more responsive but draw the fractal a bit slower.

·        Clamp Low                  : This is a value between 0 and 1 which controls the lower boundary cut-off for the 3d fractal.  Leave this at zero most all of the time.

·        Clamp High                  : This is a value between 0 and 1 which controls the maximum boundary cut-off value for the 3d fractal. 

·        Clamp Scale                 : This is a value that controls the scale factor of the previously clamped value.  Leaving this at one is generally best most of the time.  By tweaking these sliders you can control the overall look and shape of your 3d fractal image.

·        Color Palette                : This selects one of a set of provided color palettes to choose from.

 

 

Future Development Tasks:

 

·        Release as open source.

·        Get threading with micro-jobs working perfectly.

·        Allow the user to interactively control the job size and number of simultaneous physical threads.

·        Allow the user to save and load their favorite Mandelbrot locations.

·        Add a background skybox to the 3d view.

·        Improve the fractal pixel shader.

·        Add support for infinite resolution floating point numbers.

·        Improve the user interface for the 3d view.

·        Fix the user interface layout after a window resize is performed.

·        Allow the user to create their own custom color palettes.

·        Add support to import color palettes and Mandelbrot data from other popular software.

·        Add support for Julia curves and possibly other fractal equations.