Fractals/fragmentarium
< Fractals
"Fragmentarium is an open source, cross-platform IDE by Mikael Hvidtfeldt Christensen [1] for exploring pixel based graphics on the GPU. It is inspired by Adobe's Pixel Bender, but uses GLSL, and is created specifically with fractals and generative systems in mind."
This in unofficial wiki about it.
Intro
How to do it on Ubuntu :
get
Install :
- cmake 3
- Qt 4
- C++ compiler
- X11
- OpenGL development libs
- Git if fetching the source directly from the repository
sudo apt-get install build-essential libx11-dev mesa-common-dev libgl1-mesa-dev libglu1-mesa-dev libxext-dev libqt4-opengl-dev
Get source :
git clone https://github.com/Syntopia/Fragmentarium
build
cd Fragmentarium cd Fragmentarium-Source cd "Build - Linux" sh build.sh
or in the case of 3Dickulus version of Fragmentarium (v1.0.13) :
http://www.digilanti.org/fragmentarium/
1. unzip Fragmentarium-<vers>-3Dickulus.zip in ~/<your code projects> 2. cd ~/<your code projects>/Fragmentarium-<vers>-3Dickulus 3. execute the mklinux.sh script to build IlmBase OpenEXR and Fragmentarium 4. move the Fragmentarium folder with executable and support files to a suitable working location. 5. test everything!
There is also a mkmingw.bat file, same steps as above with mkmingw.bat instead of mklinux.sh at step 3, for windows (tested on 7/8). Requires Qt5 for windows installed with the MinGW package (standard from Qt website?). Both require CMake installed.
The sh and bat scripts call cmake to create the make files, compile and install. They will both install a working version in <your code projects>/Fragmentarium-<vers>-3Dickulus/Fragmentarium folder. For linux and mac the Qt libraries are installed at the system level so it should run at this point. On windows you will have to copy the Qt and mingw DLLs into the same folder as the executable or make adjustments to your setup so these are available at run time. As of this writing the required dlls are...
MinGW dlls icudt52.dll icuin52.dll icuuc52.dll libgcc_s_dw2-1.dll libstdc++-6.dll libwinpthread-1.dll Qt dlls Qt5Core.dll Qt5Gui.dll Qt5OpenGL.dll Qt5Script.dll Qt5Widgets.dll Qt5Xml.dll
QtCreator will also compile Fragmentarium but, for now, it does not compile OpenEXR, this will have to be done by executing the commands in the sh or bat script up to the point where OpenEXR static libs and development includes are installed in <your code projects>/Fragmentarium-<vers>-3Dickulus/OpenEXR.
run
Go to the ~/Fragmentarium/Fragmentarium-Source directory, then run Gui program :
cd ~/Fragmentarium/Fragmentarium-Source ./Fragmentarium-Source
Example output :
- OpenGL Vendor: NVIDIA Corporation - OpenGL Version: 4.3.0 NVIDIA 319.32 - OpenGL Renderer: GeForce GTX 770/PCIe/SSE2 - OpenGL Shading Language Version: 4.30 NVIDIA via Cg compiler
Save
Image
- use screeenshot ( key PrtScn ) or Menu/Render/Save Screen Shot...
- Menu/Render/High Resolution and Animation Render
You can render animations larger than viewport size. In the ToolBar set the Buffer Size to the tile size you want ie:64x36, then in the Menu/Render/High Resolution and Animation Render dialog set the multiplier (slider at the top) to "20" to produce images @ 1280x720. Using a small tile size will allow the GUI and desktop to remain responsive because the GPU will be doing a lot of small things instead of one big thing ;)
Features
Mouse
Left mousebutton: translate center. Right mousebutton: zoom. Wheel: zoom A/D: left/right W/S: up/down Q/E: zoom in/out
See help for more
Sliders
It is very usefull and not common feature :
uniform float Zoom; slider[0,1,100] NotLockable
Examples
Progressive2D.frag
This is a utlity program for setting up anti-aliased 2D rendering. It is used by :
- Mandelbrot.frag (
I have changed for Mandelbrot set :
- center to (-0.5,0)
- zoom to 0,6667
These are default values from Fractint
uniform vec2 Center; slider[(-10,-10),(-0.75,0),(100,100)] NotLockable
uniform float Zoom; slider[0,0.66667,100] NotLockable
Julia set
Binary decomposition of interior

#include "2D.frag"
#group Julia set
// maximal number of iterations = quality of image
// but also ability to fall into circlae with radius ar
// around alfa fixed point
// if to big then all not escaping points are unknown ( green)
uniform int iMax; slider[1,1000,10000]
// escape radius = er; er2= er*er >= 4.0
uniform float er2; slider[4.0,100.0,1000.0]
// attrating radius (around fixed point alfa) = ar ; ar2 = ar*ar
uniform float ar2; slider[0.000001,0.0001,0.003]
//
//uniform float m; slider[0.0,1.0,1000.0]
vec2 c = vec2(-1.0,0.0); // parameter of quadratic polynomial fc(z)= z^2 + c
vec2 za = vec2(0.0,0.0); // alfa fixed point
// Zoom=0.85;
vec3 GiveColor( int type)
{
switch (type)
{
case 0: return vec3(1.0, 0.0, 0.0); break; //unknown
case 1: return vec3(0.0, 1.0, 0.0); break; // interior right
case 2: return vec3(0.0, 0.0, 1.0); break; // interior left
case 3: return vec3(1.0, 1.0, 1.0); break; // exterior
default: return vec3(1.0, 0.0,0.0); break;}
}
// compute color of pixel = main function here
vec3 color(vec2 z0) {
vec2 z=z0;
int type=0;
// 0 =unknown; interior right =1; interior left = 2
// exterior =3;
int i=0; // number of iteration
// iteration
for ( i = 0; i < iMax; i++) {
// escape test
if (dot(z,z)> er2) { type = 3; break;}// exterior
// attraction test
if (dot(z-za,z-za)< ar2)
{
if (z.x>za.x) { type = 1; break;}// interior right
else { type = 2; break;}// interior left
}
z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
}
return GiveColor(type);
}// Write fragment code here...
Modified binary decomposition of interior

#include "2D.frag"
#group Julia set
// maximal number of iterations = quality of image
// but also ability to fall into circlae with radius ar
// around alfa fixed point
// if to big then all not escaping points are unknown ( green)
uniform int iMax; slider[1,6,10000]
// escape radius = er; er2= er*er >= 4.0
uniform float er2; slider[4.0,100.0,1000.0]
// attrating radius (around fixed point alfa) = ar ; ar2 = ar*ar
uniform float ar2; slider[0.000001,0.0001,0.03]
//
//uniform float m; slider[0.0,1.0,1000.0]
vec2 c = vec2(-1.0,0.0); // parameter of quadratic polynomial fc(z)= z^2 + c
vec2 za = vec2(0.0,0.0); // alfa fixed point
int iPeriod =2;
// Zoom=0.85;
vec3 GiveColor( int type)
{
switch (type)
{
case 0: return vec3(1.0, 0.0, 0.0); break; //unknown
case 1: return vec3(0.0, 1.0, 0.0); break; // interior up
case 2: return vec3(0.0, 0.0, 1.0); break; // interior down
case 3: return vec3(1.0, 1.0, 1.0); break; // exterior
default: return vec3(1.0, 0.0,0.0); break;}
}
// compute color of pixel = main function here
vec3 color(vec2 z0) {
vec2 z=z0;
int type=0;
// 0 =unknown; interior right =1; interior left = 2
// exterior =3;
int i=0; // number of iteration
int p;
// iteration
for ( i = 0; i < 100; i++) {
// escape test
if (dot(z,z)> er2) { type = 3; return GiveColor(type);}// exterior
if (dot(z-za,z-za)< ar2) break; // interior , non-escaping
z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
}
// non-escaping points
z=z0;
for ( i = 0; i < iMax; i++) z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
// {
if (z.y>za.y) { type = 1;}// interior up
else { type = 2; }// interior down
// }
return GiveColor(type);
}
Components
#include "2D.frag"
#group Julia set
// maximal number of iterations = quality of image
// but also ability to fall into circlae with radius ar
// around alfa fixed point
// if to big then all not escaping points are unknown ( green)
uniform int iMax; slider[1,1000,10000]
// escape radius = er; er2= er*er >= 4.0
uniform float er2; slider[4.0,100.0,1000.0]
// attrating radius (around fixed point alfa) = ar ; ar2 = ar*ar
uniform float ar2; slider[0.000001,0.0001,0.003]
//
//uniform float m; slider[0.0,1.0,1000.0]
vec2 c = vec2(-0.75,0.0); // parameter of quadratic polynomial fc(z)= z^2 + c
vec2 za = vec2(-0.5,0.0); // alfa fixed point
vec3 GiveColor( int type)
{
switch (type)
{
case 0: return vec3(1.0, 0.0, 0.0); break; //unknown
case 1: return vec3(0.0, 1.0, 0.0); break; // interior right
case 2: return vec3(0.0, 0.0, 1.0); break; // interior left
case 3: return vec3(1.0, 1.0, 1.0); break; // exterior
default: return vec3(1.0, 0.0,0.0); break;}
}
// compute color of pixel = main function here
vec3 color(vec2 z0) {
vec2 z=z0;
int type=0;
// 0 =unknown; interior right =1; interior left = 2
// exterior =3;
int i=0; // number of iteration
// iteration
for ( i = 0; i < iMax; i++) {
// escape test
if (dot(z,z)> er2) { type = 3; break;}// exterior
// attraction test
if ((dot(z-za,z-za)< ar2) && (i % 2) )
{
if (z.x>za.x) { type = 1; break;}// interior right
else { type = 2; break;}// interior right
}
z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
}
return GiveColor(type);
}
Checkerboard
A parabolic Julia set with ternary decomposition of interior (parabolic checkerboard for rotation number 1 over 2 )

#include "2D.frag"
#group Julia set
// maximal number of iterations = quality of image
// but also ability to fall into circle with radius ar
// around alfa fixed point
// if to big then all not escaping points are unknown ( red)
uniform int iMax; slider[1,1000,10000]
// escape radius = er; er2= er*er >= 4.0
uniform float er2; slider[4.0,100.0,1000.0]
// attrating radius (around fixed point alfa) = ar ; ar2 = ar*ar
uniform float ar2; slider[0.000001,0.0007,0.0007]
//
vec2 c = vec2(-0.75,0.0); // initial value of c
vec2 za = vec2(-0.5,0.0); // alfa fixed point
vec3 GiveColor( int type)
{
switch (type)
{
case 0: return vec3(1.0, 0.0, 0.0); break; //unknown = red
case 10: return vec3(0.0, 1.0, 0.0); break; // interior right up = green
case 11: return vec3(0.0, 0.5, 0.0); break; // interior right down = dark green
case 20: return vec3(0.0, 0.0, 1.0); break; // interior left up = blue
case 21: return vec3(0.0, 0.0, 0.6); break; // interior left down = dark blue
case 3: return vec3(1.0, 1.0, 1.0); break; // exterior = white
default: return vec3(1.0, 0.0,0.0); break;}
}
// compute color of pixel = main function here
vec3 color(vec2 z0) {
vec2 z=z0;
int type=0;
// 0 =unknown; interior right =1; interior left = 2
// exterior =3;
int i=0; // number of iteration
// iteration
for ( i = 0; i < iMax; i++) {
// escape test
if (dot(z,z)> er2) { type = 3; break;}// exterior
// attraction test
if ((dot(z-za,z-za)< ar2) && (i % 2) )
{ if (z.x>za.x) {type = 10;} // interior left
else type=20; // interior right
if (z.y>za.y) type += 1; // up or down
break;
}
z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
}
return GiveColor(type);
}
Mandelbrot set
LSM
- map : complex quadratic map
- algorithm = escape time ( LSM )
- color
- interior : solid color = black = vec3(0.0)
- exterior : level set method with gray gradient = vec3(1.0- float(i)/float(iMax))
// https://syntopia.github.io/Fragmentarium/usage.html
#include "2D.frag"
#group Simple Mandelbrot
// Creates a sliders. The values in the brackets are minimum, default, and maximum values.
// maximal number of iterations
uniform int iMax; slider[1,10,1000]
// er2= er^2 wher er= escape radius = bailout
uniform float er2; slider[4.0,4.0,1000]
// compute color of pixel
vec3 color(vec2 c) {
vec2 z = vec2(0.0); // initial value
// iteration
for (int i = 0; i < iMax; i++) {
z = vec2(z.x*z.x-z.y*z.y, 2*z.x*z.y) + c; // z= z^2+c
if (dot(z,z)> er2) // escape test
return vec3(1.0- float(i)/float(iMax)); // exterior
}
return vec3(0.0); //interior
}
Binary decomposition

algorithm = binary decomposition of target set ( and it's preimages = level sets )
#include "2D.frag"
#group Simple Mandelbrot
// maximal number of iterations
uniform int iMax; slider[1,100,1000]
uniform float er2; slider[4.0,1000.0,10000.0]
// compute color of pixel
vec3 color(vec2 c) {
vec2 z = vec2(0.0); // initial value
// iteration
for (int i = 0; i < iMax; i++) {
z = vec2(z.x*z.x-z.y*z.y,2*z.x*z.y) + c; // z= z^2+c
if (dot(z,z)> er2) // escape test
// exterior
if (z.x>0){ return vec3( 1.0);} // upper part of the target set
else return vec3(0.0); //lower part of the target set
}
return vec3(0.0); //interior
}
Doc
- official pages :
- Fractalforums :
- flicker group [9]
- deviantart
- commons : Category:Fragmentarium
References
- ↑ Mikael Hvidtfeldt Christensen
- ↑ Fragmentarium home page
- ↑ github page
- ↑ blog
- ↑ Fragmentarium official FAQ
- ↑ Fractal Forums page
- ↑ programming page
- ↑ FF gallery
- ↑ flicker group
- ↑ deviantart search
- ↑ Fragmentarium deviantart group