Home Page
Projects > Julia Fractals
Search:
Julia Fractals Thumbnail
Julia Fractals v0.61
Completed
Render Julia and Mandelbrot fractals. Also includes a 3D screen saver.
Rating: 8 (This project is still too much in an early stage (though getting further) for a higher rating.)
Project Time: 12/16/2008-1/7/2011: 16
Languages: C
Requirements:
Downloads: Binary Source (See any updates below for prior versions)
Sections: Information, Content, Concepts, Updates, Comments
Information
This renders escape-time fractals from the Julia set, as opposed to my Fractal Landscape project which makes Random Fractals. These are basically a type of recursive math function that makes beautiful infinitely zoomable patterns.
Content

Escape-time fractals differ from the other types of fractals in that each point in the infinite 2D plane can be calculated without knowing information about any of the other points or geometry due to a recursive math function ran on the coordinates. The other types of fractals all take geometric shapes and subdivide them recursively through geometric processes to make patterns. What’s neat about the escape-time fractals is that the beautiful patterns are a coincidental result of the math functions, while the other types of fractals are specifically designed to be visual.


This project is currently in its infancy and there’s still a lot I plan on doing with it until I consider it finished.

This project now contains 3.25 implementations:
  • 1A) Software rendered fractals displayed through Windows APIs [GDI] (JuliaFractalsNoOGL.exe)
  • 1B) Software rendered fractals displayed through OpenGL (JuliaFractals.exe)
  • 2A) GPU rendered fractals displayed through DirectX (JuliaFractalPixelShader-Normal.bat)
  • 2B) Multiple GPU rendered fractals displayed through DirectX in a rotating environment cube screen saver (JuliaFractalPixelShader-ScreenSaver.bat)

Screenshots:

Mandelbrot:
Mandelbrot image Mandelbrot image
Mandelbrot image Mandelbrot image
Mandelbrot image Mandelbrot image
Julia Set for: Real=-0.4, Imag=0.6 ( c=(φ−2)+(φ−1)i )
Julia Set image Julia Set image
Configuration Dialog:
Julia Fractal Configuration Dialog


v0.15 Screenshots:
View v0.15 Screenshots

Zoom Level 0 (0%)
Zoom Level 0
Zoom Level 1 (200%)
Zoom Level 1
Zoom Level 2 (800%)
Zoom Level 2
Zoom Level 2a (800%)
Zoom Level 2
Zoom Level 3 (3,200%)
Zoom Level 3
Zoom Level 3a (3,200%)
Zoom Level 3
Zoom Level 4 (12,800%)
Zoom Level 4
Zoom Level 5 (51,200%)
Zoom Level 5
Zoom Level 7 (819,200%)
Zoom Level 7


Software Rendered Controls:
  • Left click (mouse down, actually): Zoom in by 200% around the point clicked
  • Right click (mouse down, actually): Zoom out by 200%
  • =: Double the current detail level (This is needed whenever you see scattered lone black pixels in an area)
  • -: Halve the current detail level (If things are going too slow, this helps out a lot)
  • w/a/s/d: Pan the screen 1/16th in the direction up/left/down/right
  • Enter: Open the configuration dialog
  • Resizing the window: Change the resolution of the rendered fractal

Do note that the size of the window matters on both how detailed the current zoom level is and how long it takes to render. Each pixel is counted as a coordinate in the fractal space and needs to be calculated individually, so like in ray tracing, the number of pixels is a major factor in how long each screen takes to render.


For best zooming pattern results, zoom in on areas that are not a solid color.


Mandelbrot uses the Configuration:
  • Use Point (C): Yes
  • Real: 0
  • Imag: 0
Julia Sets have Use Point (C) turned off and can use any numbers for Real and Imag. See the wikipedia page for some examples.

Pixel Shader Normal Version:

The Pixel Shader version renders 100% of the fractal for each frame on the GPU. It is much faster and much smoother :-).

Unfortunately, it has a few problems. The minor problem is the colors aren’t completely matched and are a tiny bit less warm. The major problem is that the GPU uses 32 bit floating point numbers instead of 64 bit (doubles) so the resolution is much lower, and you can’t zoom in nearly as much :-\.

The primary controls are the same for the normal version, except you hold down the mouse buttons to zoom in/out.


Pixel Shader Screen Saver Version:

The screen saver version uses the same technology and base codebase as the normal version, but adds a new layer of visuals by rendering multiple fractals into textures and displaying them in a rotating environmental 3D cube around the user. The fractals on each face all zoom in and out of their own accord at different speeds.

An optional configuration file comes with the screen saver to overwrite the default screen saver mode settings. The screen saver can be run in both Full Screen and Windowed modes which have some differences:

  • Full Screen Mode: Any mouse or keyboard activity will end the program.
  • Windowed Mode: The titlebar displays current configuration settings, which can be changed realtime through shortcut keys.

A special “shrink constant” tells the program the pixel dimensions of the texture to render the fractal into when compared against the size of the actual target window. Changing this value affects the quality and render speed of the fractals rendered to each cube face.

Each of the 6 different faces (5 different fractals) all zoom in and out continuously on the same point (for that fractal). I didn’t feel like developing the code to choose good random points to zoom in on for aesthetics (and shift them real time) because I basically accomplished what I wanted with this and didn’t want to spend the extra time fine tuning that functionality.

The mode set through the configuration file can be overwritten by passing a command line parameter. The first argument can be either “ScreenSaver” or “Normal” to overwrite the mode setting. I have included batch files to easy reproduce this functionality.

I highly recommend that before you run the screen saver for the first time in full-screen-mode, that you first run it in non-full-screen-mode but maximized, and play with the settings until it looks its best and runs smoothly. Once you have accomplished this you can copy over the configurations (from the titlebar) into the configuration file.


Pixel Shader Screen Saver Version Configuration and Controls:
Setting NameDefaultShortcut KeysDescriptionShort Name (Shown in title bar)
Mode
ModeNormalThe mode of the program. Allowed values are: Normal, ScreenSaver.
Default screen dimensions
IsFullScreenNIn full screen mode any mouse or keyboard activity stops the process
Width804Window width and height are in pixels. They are modified if in full screen mode.
Height536See description for “Width”
Rendering quality
ShrinkConstant0.5S= +.05
s= -.05
Amount to shrink fractal render textures from the primary surface dimensions (affects quality and speed)SC
TextureFilterANIS...n= NONE
l= LINEAR
a= ANIS...
Filtering type for resizing textures.
Allowed values are: NONE, LINEAR, ANISOTROPIC
TexF
DetailLevel200D= *2
d= /2
The detail level of the fractals (max iterations until escaping). This affects quality and speed. The higher the value the more qualityDL
Animation settings
ViewAngle2.0944 (PI/1.5)V= +.1
v= -.1
Perspective viewing angle in radians.VA
XRot.006X= +.001
x= -.001
Rotation speed along X axisXR
YRot.002Y= +.001
y= -.001
Rotation speed along Y axisYR
ZRot.010Z= +.001
z= -.001
Rotation speed along Z axis (Note Z axis collides with both X and Y axis)ZR
IsRotatingYr= ToggleIf the world is rotatingRot
IsPlayingYp= ToggleIf the fractals are animating (zooming in and out)Play
IsImmediateNi= ToggleWhether the animation tries to sync to the vertical retrace period of the monitor or displays immediatelyImm
Other shortcut keys
eExit the program

To Do:
  • Optimization: Speed optimization with intelligent escape (detail) level calculations
  • Select zoom area via a dragged box: While clicking will still be supported to zoom in on an area, the user will also be able to drag the mouse to create a selectable box area to zoom in on
  • Non-XP dependency: Make a Linux port :-)
  • Infinite Zoom: Double precision floating point calculations under-run at the 24th zoom level :-(.
Concepts
Graphics, math algorithms
Updates
Julia Fractal now a 3D Screen Saver @ 2011-01-07 11:31:35 - Download

I was in the mood a few nights ago to do something silly and fun, so I updated the Julia Fractals project to create a 3D screen saver out of it :-). Your view is inside a rotating 3D cube with a different Julia Fractal rendering to each face. The fractals all zoom in and out of their own accord at different speeds.


The version number is now at 0.61 [source]. This update only modified the Pixel Shader portion of the project and not the software rendered one. The Julia Fractal Pixel Shader can now run in “Screen Saver” or “Normal” mode depending on command line parameters or the configuration file.


The updates are as follows:
  • Screen saver mode added:
    • An optional configuration file is provided to overwrite the default screen saver mode settings.
    • The screen saver can be run in both Full Screen and Windowed modes which have some differences:
      • Full Screen Mode: Any mouse or keyboard activity will end the program.
      • Windowed Mode: The titlebar displays current configuration settings, which can be changed realtime through shortcut keys.
    • A special “shrink constant” tells the program the pixel dimensions of the texture to render the fractal into when compared against the size of the actual target window. Changing this value affects the quality and render speed of the fractals rendered to each cube face.
    • Each of the 6 different faces (5 different fractals) all zoom in and out continuously on the same point (for that fractal). I didn’t feel like developing the code to choose good random points to zoom in on for aesthetics (and shift them real time) because I basically accomplished what I wanted with this and didn’t want to spend the extra time fine tuning that functionality.
    • The mode set through the configuration file can be overwritten by passing a command line parameter. The first argument can be either “ScreenSaver” or “Normal” to overwrite the mode setting.
  • Added the ability to render any Julia fractal through the pixel shader instead of just the Mandelbrot Fractal.
  • The source code has been split up into multiple files for better organization (Fractal rendering engine interfaced with D3D, “Normal Run” mode, the “Screen Saver” mode, Settings, and the Loader).
  • Fractal information is now held in a structure instead of global variables so multiple fractals can be rendered.
  • Added a maximum zoom amount variable to make sure floating point underrun does not occur.
  • The pixel shader is now held in the executable as a resource instead of as an extra file.

I also heavily edited the project description/notes during this update because I had noticed that I had forgotten to do that for the last few updates and they were very outdated.

Dakusan License v2.0 @ 2009-11-04 16:06:57 - Download

I have updated the licensing information across the board for my website and all its projects to the Dakusan License v2.0, a slightly modified version of the Original BSD License.

The Copyright page and all project downloads have been updated accordingly.

Julia Fractal v0.51 and Pixel Shader Version @ 2009-10-22 10:39:50 - Download
v0.51: Binary | Source

Project Updates:
  • Optimizations:
    • Changed lots of signed numbers to unsigned for theoretical better resolution in the long run.
    • In the coloring algorithm, “Bailout Radius”, and “Power” are constants, so I removed (commented out) their variables and turned anything that used them (i.e. floating point functions) into constants. This removed a lot of unnecessary floating point calculations for each pixel.
    • Added some precalculations into the fractal drawing section to speed up pixel calculations.
  • Fixes:
    • The coordinates of the moused over pixel were being improperly calculated because I had forgotten the window was being drawn and calculated in a bottom to top fashion (Y=0 is at the bottom).

New Pixel Shader Implementation:

I have made a new sub project, available in the binary and source downloads, that might be eventually integrated into the main project. This proof of concept renders 100% of the fractal for each frame on the GPU. It is much faster and much smoother :-). See the Content Section for more information.

Julia Fractal v0.50 with lots of updates @ 2009-10-20 14:47:41 - Download
v0.50: Binary | Source

Project Updates:
  • Much Better coloring: I played around with coloring algorithms and color scales a bit and finally came up with something I like. There is still a bad problem though where colors run together horribly when there isn’t good resolution on a section.
  • Added OpenGL Engine: The Win32 GDI engine didn’t look very good when animating, so I added an OpenGL render engine. They can be chosen through the Configuration Dialog. This also makes the project 1 step closer to a Linux port. :-)
  • Added configuration dialog with many options (Enter key)
    • Boundaries: Boundaries can now be seen and manually set. These are normally changed through mouse clicks and w/a/s/d keys.
    • Window Dimensions: Window dimensions can now be seen and manually set. These are normally changed by resizing the window.
    • Julia Fractal Config [NEW OPTION]: Configure what Julia Fractal is shown.
    • Detail Level: Detail level can now be seen and manually set. This is normally changed by the +/- keys.
    • Enable Animation [NEW OPTION]: Since animating can slow things down and is kind of unnecessary, I have added an option to bypass it.
    • Zoom: This displays the zoom level, which is determined by the X boundaries.
    • Current Pixel Information: Displays the information about the currently moused over pixel.
    • Render Engine [NEW OPTION]: Choose what render engine to use.

Other Update Information:
  • New screenshots in the content section and old screenshots are now hidden behind a link.
  • Version number has been updated to 0.50.
  • Rating has been raised from a 5 to a 7 since the project is a little further along.
  • Updated the Project Time span and Project Time to 10 hours, since I’ve spent about 5 more hours on it.
  • Updated content section and readme to reflect new updates.
  • I am including a binary version (NoOGL) that does not include OpenGL to remove the dependency if the person doesn’t have it.
Added Readme files to all project downloads @ 2009-09-19 05:35:19

Binary and source zip downloads for all Projects now have readme files in them, except as mentioned below.

This only applies to the Draw Image Project in Web Scripts, and not the Directory Manager project (The only project zip file now without a readme).

Julia Fractals: Added Animation @ 2008-12-26 00:23:12 - Download
v0.15: Binary | Source

I added animation when zooming in and out. This is achieved by drawing the new fractal level into a buffer, and then resizing and translating both fractal level buffers appropriately over a fixed number of frames to animate a zoom effect. It would, of course, be optimal to redraw the entire fractal on each frame of the animation, but this would be a MAJOR speed hit.

The visual quality doesn’t look as good as I’d like at the moment due to XP’s StretchBlt API not using very good resizing algorithms, but it will do for now. Basically, colors show up too brightly when being resized. I can just plug in another resizing algorithm later that will give better results, possibly using a GPU API (DirectX or OpenGL) for optimal results and speed.

I also cleaned up the comments a little.


Time spent on update: 2.5 hours
Julia Fractals Initial Release @ 2008-12-20 02:24:51 - Download

So I was required to read up on Mandelbrot Fractals for something this last Tuesday, and was really intrigued by the concept, so I threw this project [v0.1 binary, source] together in 2 hours that night ^_^.

I spent 40 minutes on the program outline and the fractal calculations, 20 minutes on the zooming and panning, and an hour on the coloring. The coloring part is really hard because there are no solid formulas I could find out there for them. It will possibly take a lot of experimenting and playing with algorithms and tweaking numbers if I can’t find a good algorithm for it online. The coloring is actually not technically part of the escape-time fractals (see the picture under “Formal Definition” here), only the solid black part is, and the rest can be white. However, it’s the coloring taken from a result of the algorithm that really makes the most pretty patterns in the fractal, so it’s a very important part.


The current project only shows the Mandelbrot Fractal. Future versions will allow providing parameters dynamically to view any Julia Fractal. [Added in v0.50]

Other planned updates:
  • Better coloring!!!: As previously stated, I need to spend a lot of time on coloring calculations :-\. [Added in v0.50]
  • Animated zooming: When zooming in or out on an area, the screen will animate the zoom [Added in v0.15]
  • Optimization: Speed optimization with intelligent escape (detail) level calculations
  • Select zoom area via a dragged box: While clicking will still be supported to zoom in on an area, the user will also be able to drag the mouse to create a selectable box area to zoom in on
  • View zoom level information: A dialog box and better visual GUI that allows you to see and change your current zoom level, window coordinate scales, and other information [Added in v0.50]
  • Coordinate information: Add to the GUI viewable information about each coordinate (pixel) you are mousing over including time to escape, color, and other information [Added in v0.50]
  • Non-XP dependency: Make a Linux port :-)
  • Infinite Zoom: Double precision floating point calculations under-run at the 24th zoom level :-(.

This project is too much in its infancy for a higher rating. It will be sure to go up as I work on it and add more features.


Current controls:
  • Left click (mouse down, actually): Zoom in by 200% around the point clicked
  • Right click (mouse down, actually): Zoom out by 200%
  • =: Double the current detail level (This is needed whenever you see scattered lone black pixels in an area)
  • -: Halve the current detail level (If things are going too slow, this helps out a lot)
  • w/a/s/d: Pan the screen 1/16th in the direction up/left/down/right

... It just took me an hour longer to write this post and all the documentation than it did to write the program XD. Darn documentation!


Comments
To add comments, please go to the forum page for this project (guest comments are allowed for the Projects, Posts, and Updates Forums).
Comments are owned by the user who posted them. We accept no responsibility for the contents of these comments.

No comments for this Project