Welcome to Fractal Forums

Fractal Math, Chaos Theory & Research => Mandelbulb Implementation => Topic started by: Fred Decker on January 23, 2013, 06:31:52 AM




Title: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 23, 2013, 06:31:52 AM
I think I found something interesting... I read the original post with implementation details, and the optimized formula on this site a few years back. 

Recently though, I've been obsessed with reading about physics, quantum electrodynamics specifically.  The way Richard Feynman describes the handling of "probability amplitudes" in quantum mechanics reminded me of the 3d mandelbrot problem, so I put 2 and 2 together and got this.  I've been rendering in a pretty slow engine (mathematica), so I'd be grateful if someone can try this in a faster pan/zoomable renderer.

I'll explain the derivation later if anyone is interested, but here's something i'm working on in C# which generated the scans in these links:
https://www.youtube.com/watch?v=Bv3YePo9kvw (https://www.youtube.com/watch?v=Bv3YePo9kvw)
https://www.youtube.com/watch?v=Ygr0yE-ht7k (https://www.youtube.com/watch?v=Ygr0yE-ht7k)
https://www.youtube.com/watch?v=KxFhVMsWb34 (https://www.youtube.com/watch?v=KxFhVMsWb34)

        static public double DoFractal(double x, double y, double z, int maxiters)
        {
            var iters = 0;
            var cx = x;
            var cy = y;
            var cz = z;
            while (iters < maxiters && Math.Abs(x * x + y * y + z * z) < 4)
            {
                ShrinkAndTurn(ref x, ref y, ref z, cx, cy, cz);
                iters++;
            }
            return iters;
        }

        static public void ShrinkAndTurn(ref double x, ref double y, ref double z, double cx, double cy, double cz)
        {
            double theta, phi;
            if (x == 0 && y == 0)
                theta = 0;
            else
                theta = 2* Math.Acos(x / Math.Sqrt(Math.Abs(y) * Math.Abs(y) + Math.Abs(x) * Math.Abs(x)));
            if (x == 0 && z == 0)
                phi = 0;
            else
                phi = 2* Math.Acos(x / Math.Sqrt(Math.Abs(z) * Math.Abs(z) + Math.Abs(x) * Math.Abs(x)));
            var mag = (y * y + z * z + x * x);
            x = cx + mag * Math.Cos(y < 0 ? -theta : theta) * Math.Cos(z <= 0 ? phi : -phi);
            y = cy + mag * Math.Sin(y < 0 ? -theta : theta);
            z = cz - mag * Math.Cos(y < 0 ? -theta : theta) * Math.Sin(z <= 0 ? phi : -phi);
        }


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 23, 2013, 08:02:17 AM
Here's the mathematica render, 200x200x200 points.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: cKleinhuis on January 23, 2013, 08:03:39 AM
hi there, the animations seem to "jump" at the end, would love to see this object in 3d ;)

according to your animations you have mandelbrot shapes on imaginary and secondimaginary axis ?



Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: cKleinhuis on January 23, 2013, 08:05:24 AM
nice!!!


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 23, 2013, 08:06:52 AM
regarding the jump at the end, it's the resolution I'm rendering at... 500 pixels doesn't capture how quickly they change close to the axis.  I have rendered a much smaller slice, and it looks better.

and yes, it does show a 2d mandelbrot on the imaginary and 3rd axis.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: eiffie on January 24, 2013, 06:05:28 PM
I have a habit of posting questionable code off the top of my head, but here is a distance estimate for Fragmentarium :)
Code:
float DE(in vec3 z0){
vec4 z=vec4(z0,1.0),c=z;
float r=length(z.xyz);
for(int i=0;i<Iterations && r<2.0;i++){
float theta=Power*acos(z.x/length(z.xy))*sign(z.y);
float phi=Power*acos(z.x/length(z.xz))*sign(z.z);
z=pow(r,Power-1.0)*vec4(r*vec3(cos(theta)*cos(phi),sin(theta),-cos(theta)*sin(phi)),Power*z.w)+c;
r=length(z.xyz);
}
return 0.5*log(r)*r/z.w;
}

Fragmentarium will display your formulas in under a second. Give it a try if you have time.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 24, 2013, 06:54:25 PM
I have a habit of posting questionable code off the top of my head, but here is a distance estimate for Fragmentarium :)

thanks a lot! this is exactly what i was looking for... will try it tonight.  I started playing around with Fragmentarium, but I haven't quite got my head around the concept of distance estimation yet.  this looks like a good starting point at least.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 25, 2013, 05:32:01 AM
Using below (a small correction from eiffie's snippet)
Code:
float DE(in vec3 z0)
{
vec4 z=vec4(z0,1.0);
vec4 c=z;
float r=length(z.xyz);
for(int i=0;i<Iterations && r<Bailout;i++)
{
float theta =2.0*acos(z.x/length(z.xy))*sign(z.y);
float phi = -2.0*acos(z.x/length(z.xz))*sign(z.z);
z=r*vec4(r*vec3(cos(theta)*cos(phi),sin(theta),-cos(theta)*sin(phi)),2.0*z.w)+c;
r=length(z.xyz);
}
return 0.5*log(r)*r/z.w;
}

But why do I need to use vec4 instead of vec3?  What is the w axis for?  Any tips on improving detail on rendering?


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 25, 2013, 05:34:50 AM
another showing more detail on the small bulb side


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 25, 2013, 05:35:39 AM
and more detail from behind


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 25, 2013, 06:29:25 AM
last one... the main stalk


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Alef on January 25, 2013, 03:25:55 PM
Last one is good. Previous have certain sand effect. Maybe too thin structures or discontiniuaties.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 25, 2013, 03:37:26 PM
The "sand" problem is one thing I wanted to get a better understanding of... I know for sure there are very fine structures that are not showing up in these views.  Is there a way to improve this?  Or do I need to go to a different renderer?  I see people talking about other non-DE renderers, indigo, POV, etc.  Would these be better suited for what I'm trying to do?


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: eiffie on January 25, 2013, 05:54:37 PM
Fragmentarium also does DE-less rendering but the .frag file is not included in the release yet - you have to get it yourself. (github??)

The vec4 is only a shortcut. You can use a vec3 and create another variable typically called "dr". It is a running derivative calculated like this...
dr=dr*(derivative of your function)+1

You will get higher detail by lowering the "detail" slider - but you also get more sand. Just run the continuous mode longer :)


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 25, 2013, 06:24:26 PM
Good to know... thanks again!  I didn't understand the continuous mode before, but I did notice the added sand with the change in "detail" control.  Will try again tonight.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Syntopia on January 25, 2013, 09:58:43 PM
Good to know... thanks again!  I didn't understand the continuous mode before, but I did notice the added sand with the change in "detail" control.  Will try again tonight.


The sand-stuff is usually because the DE-function has problems in some regions. You could try lowering the FudgeFactor in the RayTracer tab, but there is no guarantee.

As Eiffie mentioned the latest Fragmentarium build has some support for Non-DE rendering - it can be found here: http://www.fractalforums.com/3d-fractal-generation/rendering-3d-fractals-without-distance-estimators/msg54477/#msg54477


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: knighty on January 25, 2013, 11:35:31 PM
You can also try a larger bailout value (say 10 to 100) to reduce the sand effect.


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: DarkBeam on January 25, 2013, 11:41:33 PM
It looks a lot like Rucker's brot, the oldest formula ever. Ages ago Makin rendered it  ;)
Don't waste your time fiddling with angles, somebody made general formulas already! ;)


Title: Re: Please try this... new 3d mandelbrot formula, animations included
Post by: Fred Decker on January 26, 2013, 12:42:24 AM
I'm very familiar with Rucker's solution.  I've seen (and implemented) both the original Rucker formulas, and the optimizations.  Both of those give different results.  I'll show the differences at some point, I've already got them all running side by side in mathematica.  The way he identifies the angles and rotations are different, and it makes a real difference in the escape iteration counts, and therefore shape.  The general shape is similar in a way, but definitely not the same.