Welcome to Fractal Forums

Fractal Software => Mandelbulber => Topic started by: no_gravity on September 14, 2011, 11:13:21 PM




Title: Need Help to try my own formulas with Mandelbulber
Post by: no_gravity on September 14, 2011, 11:13:21 PM
Hello!

I tried Mandelbulber and it renders really great images!

I would like to try my own formulas. So far, I managed to compile Mandelbulber from source and run it.

I guess I have to change the formula in the code, "make all" and "./install" again and then run Mandelbulber and it will run with the changed formula?

Im not sure where in the code the Mandelbulb formula is. I tried to change the code after

switch(actualFormula)
{
 case trig_DE:
  ...

in fractal.cpp. But that doesnt seem to impact the default renderings.

Any hints?


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: cKleinhuis on September 14, 2011, 11:38:46 PM
you need to rebuild the whole program after changing a line in the source code, there must be a "build.bat" file, just run it and the executable is generated with new code ....
but be sure to not destroy anything by "checking-in" .....

there exist a possibility to write formula codes "DIRECTLY IN ASSEMBLY CODE" what is a pain in the ass, but user darkbeam here is doing quite well on it ;)

regards and hello to the forums


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: no_gravity on September 15, 2011, 07:46:19 AM
Recompiling works fine now. If there would be a function isInSet(x,y,z) that I could overwrite then i would be ready to go. Maybe this part of fractal.cpp is the formula that gets iterated:

                                double r1 = pow(r, p - 1);
                                double r2 = r1 * r;
                                double th = z.GetAlfa();
                                double ph = -z.GetBeta();
                                if (Mode == 0)
                                {
                                        double p_r1_rdz = p * r1 * r_dz;
                                        double ph_phdz = (p - 1.0) * ph + ph_dz;
                                        double th_thdz = (p - 1.0) * th + th_dz;
                                        CVector3 rot(th_thdz, ph_phdz);
                                        dz = rot * p_r1_rdz + one;
                                        r_dz = dz.Length();
                                        th_dz = dz.GetAlfa();
                                        ph_dz = -dz.GetBeta();
                                }
                                CVector3 rot(p * th, p * ph);
                                z = rot * r2 + constant;
                                r = z.Length();

Im not sure what this does though. I think maybe z contains the coordinates af the current voxel as z.x, z.y and z.z?


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: marius on September 15, 2011, 08:02:46 AM
If there would be a function isInSet(x,y,z) that I could overwrite then i would be ready to go.

Mandelbulber is a ray marcher; it traces the fractal surface based on distance estimation.
It does not render the fractal as a 3d voxel cloud.

Check out syntopia's excellent posts on this topic at http://blog.hvidtfeldts.net/ (http://blog.hvidtfeldts.net/)


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: no_gravity on September 15, 2011, 11:56:42 AM
Ah, ok. So the formula first has to be transformed in some way?

What could be an easy way to try new formulas?


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: Buddhi on September 15, 2011, 09:21:39 PM
Hi

There are three types of formulas:
1) which uses analytic distance estimation: trig_DE, trig_optim (default)
2) IFS formulas and Mandelbox: menger_sponge, tglad, smoothMandelbox, kaleidoscopic, mandelboxVaryScale4D
3) rest of formulas, which uses "delta DE" algorithm for distance estimation

Third type of formula is the easiest for modification and doesn't need special knowledge about distance estimation, because it is done by external function.
So if you want to test your own formula, try to overwrite for instance hypercomplex formula:

Code:
			case hypercomplex:
{
CVector3 newz(z.x * z.x - z.y * z.y - z.z * z.z - w * w, 2.0 * z.x * z.y - 2.0 * w * z.z, 2.0 * z.x * z.z - 2.0 * z.y * w);
double neww = 2.0 * z.x * w - 2.0 * z.y * z.z;
z = newz + constant;
w = neww;
r = sqrt(z.x * z.x + z.y * z.y + z.z * z.z + w * w);
break;
}

There are two very important variables:
z - iteration vector (z.x,z.y,z.z) which you use for your formula ( z = formula(z) )
r - length of iteration vector - must be calculated after formula calculation - needed for bailout checking. If formula is 3-dimensional you can use r = z.Length();

You can't implement there formula like isInSet(x,y,z), because there has to be possibility to estimate distance to fractal surface. The output of formula can't be binary. It has to return actual length of iteration vector, which is used for distance estimation function.

If you put there your formula and re-compile the program, you can test it by selecting "Hypercomplex" formula.

If you use third type of formula, you don't have to transform formula in any special way.

Adding of completely new formulas (by not overwriting) is much more difficult, because you have to make some additional changes in other parts of program.

Edit: there is third also important variable: constant which is c from e.g. z = z^2 + c formula.


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: no_gravity on September 16, 2011, 12:01:01 AM
Hello Buddhi,

first of all congratulations on this great piece of software!

I dont know if its possible to fit my formula inside the existing loop. I tried it for a while, but to no avail. My formulas are not the usual z=z^2+c type of functions. They use different kind of data structures, different break conditions etc.

As an example, imagine the following function isInSet(x,y,z): Via a hash function, for each point(x,y,z) you create a position on a chess board. Then you let 2 programs play from that position. If white wins, the point is in the set.

Now when I want to squeeze that into the code for case hypercomplex, I would have to iterate on an iteration vector z. But thats not possible. Because the hash function I use to create a chess position from x,y,z is not reversible. So I cannot squeeze it back into z. And I have to calculate r, the length of the iteration vector. But what is the length of a chess position?

Or am I missing something?

I wrote my own simplistic raymarcher today. It gives me a first impression of my formulas. But I would loooove to render them in something as advanced as Mandelbulber.


Title: Re: Need Help to try my own formulas with Mandelbulber
Post by: DarkBeam on September 20, 2011, 10:29:36 PM
you need to rebuild the whole program after changing a line in the source code, there must be a "build.bat" file, just run it and the executable is generated with new code ....
but be sure to not destroy anything by "checking-in" .....

there exist a possibility to write formula codes "DIRECTLY IN ASSEMBLY CODE" what is a pain in the ass, but user darkbeam here is doing quite well on it ;)

regards and hello to the forums

If you say so... :o