Mandebulber 2.06 is finished, so now is the time to start creating version 2.07. As I wrote some time ago this release will focus on adding new formulas and transforms to mandelbulber.
I would like to invite you to development of formulas in Mandelbulber. Every help is appreciated. If some of you have some basic programing skills, below there are instructions how to write add own formulas into Mandelbulber code. Because I use Linux for development, the guide is prepared for Debian or Ubuntu. It looks a little complicated, but believe me, even person who never wrote any program can learn how to do this (on the Forum there is one guy who started based on this guide and it was his first contact with Linux and programming).
If somebody wants, a can grant write access to Mandelbulber code repository.
Writing own formulas in MandelbulberTo prepare your system to work with Mandelbulber you need to do following steps:- open Terminal application
- paste following command to install all needed software:
sudo apt-get install libqt5gui5 qt5-default libpng12-0 libpng12-dev qttools5-dev qttools5-dev-tools libgsl0-dev libgsl0ldbl libgomp1 git qtcreator
it will ask you for admin (root) password
- download this file:
https://github.com/buddhi1980/mandelbulber2/releases/download/2.06/mandelbulber2-2.06.tar.gz- unpack it somewhere (e.g. by using file manager)
- open unpacked mandelbulber2-2.06 folder with File Manager
- right click in File Manager and click Open In terminal
- run install script by typing command:
./install (don't forget dot and slash)
after compilation it will ask about your admin password to install all the files
Now Mandelbulber is installed in your system and you have all needed files on place
Retrieving fresh source from git repository:- create 'git' folder in your home directory
- open some new Terminal
- type:
cd git
git clone
https://github.com/buddhi1980/mandelbulber2.git Now you have the newest version of Mandelbulber code in your system
Compilation in QtCreator- open git/mandelbulber2/mandelbulber2/Release folder in File Manager
- open mandelbulber.pro in Qt Creator
- when it's open, click Configure Project
- unfold Compiler Messages window (on the bottom of window)
- click hammer icon (build - left/bottom corner)
the program will be compiled. If you did all steps correctly, shouldn't be error here
- try to run the program using green arrow
Adding new formulas:- fractal_list.hpp:30 - enum enumFractalFormula - here is the list of formulas. Add new formula at the end with unique number.
- fractal_list.cpp:28 - void DefineFractalList(QList<sFractalDescription> *fractalList) - here is detailed list of formulas
example:
fractalList->append(sFractalDescription("Kaleidoscopic IFS", "ifs", kaleidoscopicIFS, analitycDE));
1st parameter: Displayed name of the fractal
2nd parameter: internal name of the fractal. The same name is used for UI files
3rd parameter: the same name as in enumFractalFormula
4th parameter: type of distance estimation. Most of formulas use deltaDE estimation which needs more computation but doesn't need any special code from you.
- fractal_formulas.cpp - here are definitions of function which calculate single fractal iteration. There is no adding of C constant and bailout condition here.
example:
void MandelbulbIteration(CVector3 &z, const cFractal *fractal, sMandelbulbAux &aux)
{
double th0 = asin(z.z / aux.r) + fractal->bulb.betaAngleOffset;
double ph0 = atan2(z.y, z.x) + fractal->bulb.alphaAngleOffset;
double rp = pow(aux.r, fractal->bulb.power - 1.0);
double th = th0 * fractal->bulb.power;
double ph = ph0 * fractal->bulb.power;
double cth = cos(th);
aux.r_dz = rp * aux.r_dz * fractal->bulb.power + 1.0;
rp *= aux.r;
z = CVector3(cth * cos(ph), cth * sin(ph), sin(th)) * rp;
}
arguments:
z - input / output variable containing iteration vector
const cFractal *fractal - read only container with all fractal parameters
sMandelbulbAux &aux - input / output auxiliary structure containing values needed for instant to calculate estimated distance
All parameters and data structures are defined in fractal.h
- fractal_formulas.hpp - here are declaration of functions
- compute_fractal.cpp:42 - void Compute(const cFourFractals &four, const sFractalIn &in, sFractalOut *out) - here is the main iteration loop. You need to add in line about 290 calling of your new function.
In line 305 you can do some exceptions for adding C constant
//addition of constant
switch (fractal->formula)
{
case menger_sponge:
case kaleidoscopicIFS:
case aexion:
case mandelbulb5:
case mandelbox103:
case quaternion104:
case mengerSponge105:
case mandelbulb6Beta:
case benesiTransforms:
{
break;
}
default:
{
if (in.common.juliaMode)
{
z += in.common.juliaC;
}
else
{
z += c * in.common.constantMultiplier;
}
break;
}
}
In line 344 there are bailout conditions. Now all formulas use the same condition. You you need to create any special escape condition then just tell me.
//escape conditions
if (Mode == calcModeNormal)
{
if (r > in.common.bailout)
{
out->maxiter = false;
break;
}
}
- initparameters.cpp:389 - void InitFractalParams(cParameterContainer *par) - here are definition of names of parameters which are used in UI and settings files. If you add new formula then try to utilize existing names. If there is nothing which fits to your needs, then add new one
- fractal.cpp, fractal.hpp - here are data structures for fractal parameters. There is also copying of values from internal parameter representation to data structures which you use in fractal functions
User interface for new fractals:To create UI files you can use Qt Designer application. The best would be if you make them based on existing files. All ui files are located in git/mandelbulber2/qt_data folder. Names start with fractal_ and the rest of name is the same as internal fractal name. Even if formula doesn't use any parameters, you need to create UI file which is the same like fractal_quaternion.ui (some kind of dummy). To have UI available from the program you have to copy ui file to /usr/share/mandelbulber2/qt_data folder.
In UI files there are very important names of edit fields. The program connects automatically edit fields with adequate parameters and connects edit fields with sliders/knobs. But to make it working first part of the name must describe type of edit widget. Use following prefixes:
- spinbox_ - scalar value
- slider_ - slider for scalar value
- checkBox_ - boolean value
- spinboxd3_ - edit field for knob for angle. This is for 3 dimensions, where angles are stored in CVector3 data type. Last letter of name must indicate axis name (_x, _y, _z)
- dial3 - knob for spinboxd3
- spinboxInt - spinbox for integer value
- sliderInt - slider for spinboxInt
- logedit - edit field for high variation value (only positive)
- logslider - slider for logedit which changes value in logarithmic scale
- vect3 - 3d vector (related to CVector3 data type). Name must ends with axis name[/li][/list]
Rest of the name of edit field must be the same as defined in initparameters.cpp