Welcome to Fractal Forums

Fractal Software => 3D Fractal Generation => Topic started by: steamraven on November 18, 2009, 07:36:00 PM




Title: Implementation: 3D mandelbrot type fractal
Post by: steamraven on November 18, 2009, 07:36:00 PM
Hey I am a fractal newbie, but I found the http://www.skytopia.com/project/fractal/mandelbulb.html and I love it!

As an exercise in programming (and possible stupidity) I would like to write my own renderer (in OpenCL).  I took a look at David Makin's Distance Estimator (http://www.fractalforums.com/3d-fractal-generation/true-3d-mandlebrot-type-fractal/msg8073/#msg8073) and I understand most of it except the test " if binary search count>=max binary depth".

It seems "binary search count" is only set to 0 or 1.  Does this get incremented elsewhere? Can I get some clarification?

I also am using for smooth iteration value the equation on http://linas.org/art-gallery/escape/escape.html

mu =  n + 1 - log (log  |Z(n)|) / log 2

where n is iteration at escape from radius and |Z(n)| is the last value.  (obviously for the power 8 I would use log 8 instead of log 2)

Is this right?

Thanks in advance


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: cKleinhuis on November 18, 2009, 09:14:27 PM
the binary search is for finding the exact point where the solid or inner part of the object begins
so to say, it is the exact border, the binary search used here is related to the newtonian root finding method:
you start with a point outside, and going to wards the inside until you hit an inside point, after that you know that
the border lies between the last and the current one, then you start your binary search for finding the exact position
for that border :)


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: David Makin on November 18, 2009, 10:45:29 PM
Hey I am a fractal newbie, but I found the http://www.skytopia.com/project/fractal/mandelbulb.html and I love it!

As an exercise in programming (and possible stupidity) I would like to write my own renderer (in OpenCL).  I took a look at David Makin's Distance Estimator and I understand most of it except the test " if binary search count>=max binary depth".

It seems "binary search count" is only set to 0 or 1.  Does this get incremented elsewhere? Can I get some clarification?

I also am using for smooth iteration value the equation on http://linas.org/art-gallery/escape/escape.html

mu =  n + 1 - log (log  |Z(n)|) / log 2

where n is iteration at escape from radius and |Z(n)| is the last value.  (obviously for the power 8 I would use log 8 instead of log 2)

Is this right?

Thanks in advance

Apologies if I missed it, but yes the binary search count should be incremented at each binary step and the search should continue either for a preset maximum number of steps or until the new step distance is less than a given min search value or until the difference between the estimate and the threshold is less then a given min search value.

A better version of the smooth iteration calculation is:

mu = n + (log(0.5*log(@bailout)) - log(0.5*log(|final z|)))/log(divergence)

where |z| is actually the square of the magnitude and @bailout is the bailout value this is tested against - we avoid using sqrt by testing the square and avoid using the square root in the smooth iteration calculation by using 0.5*log().
Whether or not a +1 is required in the above for a positive mu depends on how the iteration count is implimented in the formula but for mu to always be positive then n should be at least 1  i.e. bailout on the first iteration should have a count of 1 - this is irrelevant for the delta DE however since the +1's from the two positions on the ray would simply cancel out i.e. for that as far as the n's are concerned it's only their relative value that matters.
For z^2+c in the above divergence would be 2 and in fact if using a fixed constant for divergence then the log(0.5*log(@bailout)) term is irrelevant for the delta DE calculation.

The above method however has small errors at iteration boundaries specifically due to the fact that we're bailing out before the magnitude reaches infinity. In 2D these errors only really show in formulas with non-integer divergence and more especially in formulas where the divergence actually varies across the fractal however the delta DE method is more sensitive to the errors.
Using the actual divergence at bailout corrects the errors i.e. instead of using a preset constant for the divergence we instead use:

divergence = log(|final z|)/log(|penultimate z|)

where penultimate z is the value from the iteration prior to the bailout iteration - usually called zold in complex formulas, note again that |value| here is used as the square of the magnitude to avoid the square root calculation. if using the variable divergence then the log(0.5*log(@bailout)) term must be included in the calculation of the values of mu.



Title: Re: Implementation: 3D mandelbrot type fractal
Post by: lycium on November 20, 2009, 12:21:59 AM
i have found the binary search to add more noise, since even with just 8 iterations the surface is extremely convoluted, perhaps to the limit of single precision floating point. for more than 8 iterations and/or using binary search, i'd say double precision is an absolute must.

the other thing is that instead of using constant steps + binary search, it is perhaps more prudent to use unbounding spheres to ray march - this is probably far more numerically stable.


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: David Makin on November 20, 2009, 12:38:30 AM
i have found the binary search to add more noise, since even with just 8 iterations the surface is extremely convoluted, perhaps to the limit of single precision floating point. for more than 8 iterations and/or using binary search, i'd say double precision is an absolute must.

You are correct regarding the binary search if you are going as close to the "inside" as your resolution allows but if you want to render with less detail (i.e. a greater distance estimation threshold) then neglecting to use the binary search (or a weighted search) results in visible "stepping" on the image.

Edit: I just went to render an example with and without binary search and discovered to my surprise that the latest version of my own code has almost removed the issue. The problem occurs really noticeably when you use the actual adjacent solid coordinates for computing the normals but in the latest version of my own formula I instead use the DE values from the same distance from the viewpoint as the found pixel on the rays adjacent to the found pixel (i.e. without tracing to the true solid on the adjacent rays) and using this method only has minor stepping even wth a solid threshold as high as 0.1 (note that because I'm using UF I actually get the DE values for the points on the adjacent rays for the rays at the ideal 0.5 pixels offset from the central ray whereas in other implimentations it would probably be more efficient to use the rays at a whole pixel offset).


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: steamraven on November 20, 2009, 06:05:18 PM
Thank you guys for you replies.  Things are starting to make more sense.

Also, what are people using to calculate normals? 

Thanks,


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: David Makin on November 20, 2009, 06:10:58 PM
Thank you guys for you replies.  Things are starting to make more sense.

Also, what are people using to calculate normals? 

Thanks,

See this thread:

http://www.fractalforums.com/mandelbulb-implementation/calculating-normals/msg8791/#msg8791 (http://www.fractalforums.com/mandelbulb-implementation/calculating-normals/msg8791/#msg8791)


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: steamraven on November 24, 2009, 06:22:11 AM
I need another set of eyes.  I am trying to implement bugman's expansion of the power of 8, but its not working.  Here is my code:

Code:
    

float4 pos;  // the point being iterated
float4 value = (float4) 0.0f;

for (i = 0; i < max_i; i++)
    {
        #ifdef EXPANSION
            float x2 = value.x * value.x;
            float y2 = value.y * value.y;
            float z2 = value.z * value.z;
            float z4 = z2 * z2;
            
            float r2 = x2+y2;
            float r4 = r2*r2;
            

            float z = 8.0f*value.z*sqrt(r2) * (z2 - r2) * (z4 - 6.0f*z2*r2 + r4);                
            float a = 1.0f + (z4*z4 - 28.0f*z4*z2*r2 +70.0f*z4*r4 -28.0f*z2*r4*r2) / (r4*r4);
            
            // z2, z4, r2, and r4 are not used anymore
            
            float x4 = x2 * x2;
            float y4 = y2 * y2;
            float x6 = x2 * x4;
            float y6 = y2 * y4;
                        
            value = (float4)(
                a * (  x4*x4 - 28.0f*x6*y2 + 70.0f*x4*y4 -28.0f*x2*y6 + y4*y4),
                8.0f*a*value.x*value.y*( x6 - 7.0f*x4*y2 + 7.0f*x2*y4 - y6),
                z,
                0.0f);
                    
            
        #else
            float r = length(value);
            float theta = atan2(sqrt(value.x * value.x+ value.y * value.y), value.z);
            float phi = atan2(value.y,value.x);
        
            value = pown(r, 8) * (float4)(
                                        sin(theta * 8.0f) * cos(phi * 8.0f),
                                        sin(theta * 8.0f) * sin(phi * 8.0f),
                                        cos(theta * 8.0f), 0.0
                                 );
        #endif
        value += pos;

        prev_length2 = length2;        
        length2 = dot(value, value);
        if (length2 > escape2)
            break;
}

If I define "expansion" it uses the expanded polynomial, but incorrect results.  Without "expansion", it uses the trig and it works.  Any ideas?

Note: This is opencl, which is basically c with vectors.


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: ddrcoder on December 04, 2009, 09:11:25 AM
So, a quick preview (I'll post more later this week). I've taken Jan Vlietinck's awesome work on the DX11 Quaternion Julia renderer and I've adapted it for the Mandelbulb. I've got some pretty damn cool results, if I do say so myself, and with pretty amazing performance. I can now render a 1280x720 Mandelbulb in 14 milliseconds. :)

It's a little rough around the edges (literally), as I'm still tweaking the distance estimator, but I think it's a good start.
(http://i.imgur.com/JA99x.jpg)


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: Snakehand on December 09, 2009, 01:19:46 AM
I have been fiddling with a Brook+ raytracer. It is late now, and I just got some decente renderings, and thought I would post one before I head to bed:

(http://traxme.net/fractal/mandelbulb.png)

Done in "a fraction of second" on a ATI Radeon 5850 card.




Title: Re: Implementation: 3D mandelbrot type fractal
Post by: KRAFTWERK on March 10, 2010, 02:37:55 PM
I have been fiddling with a Brook+ raytracer. It is late now, and I just got some decente renderings, and thought I would post one before I head to bed:

(http://traxme.net/fractal/mandelbulb.png)

Done in "a fraction of second" on a ATI Radeon 5850 card.

Sorry to awake an old post, just curious wich formula you used on this render Snakehand.

It is seems to be the "assymmetric" bulb I am looking for...
(Different top/bottom)

Johan


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on May 30, 2010, 04:29:41 AM
Hi and sorry if I'm interrupting a specific project here.  This is something different.  I've been having a dialogue principally with Jehovajah in "...search for the holy grail continues..." section, and am convinced there is an implementation problem for one approach to M in extended Dims.  I'd love to get more to look at the ideas I'm trying to communicate there. Taken together, the messages I left are enough to duplicate my 2-d results and judge whether a 3-d generator for it exists or can be written easily.  My comments begin on page 12 and continue to the present.  Would love to show some pix, make a paper available, and provide my formula files for this in FractInt.  Someone please advise.


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: KRAFTWERK on May 31, 2010, 10:42:08 AM
No worry fracmonc, I have found what I was looking for!


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on May 31, 2010, 03:43:56 PM
K- Went to your deviantart site- very outstanding pix!  I take it most are higher exp M generalizations using mandelbulb or a variation on that.  Beautiful structures, and I see in some of them, say, suggestions of similar shapes, in the 2-d details of the 2-power I've been looking at.  I'm kinda crawling before I can walk here, with a back-to-basics approach.  I'm more interested in the basic math for an extension from the complex plane w.o. sacrificing ANY field properties in the process and believe I have found such!  While mandelbulb-type renderings are dazzling and impressive, the math does not seem very straightforward or understandable, at least to me, and while they are a sophisticated expression, they are more a product of what I call M-gymnastics than anything else.  I've done many 2-d formulae that would do things like double M bugs, lambdas, tip-to-tips, M-in a circle (what is normally found on Re axis, only mapped to unit circle), etc.  That's what I mean by M-gymnastics...anyway, mandelbulb strikes me as more of that, only in 3-d!  I'm interested in a straight and simple, meaningful extension of M into more than 2-d on a more basic and fundamental level.  Have you read the dialogue I spoke of?


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: KRAFTWERK on May 31, 2010, 04:40:31 PM
Thank you fracmonk!

I am a keen follower of your (and jehovajah:s) thread, sadly my math skills is some levels lower than yours.  O0
Has anyone implemented your new formulas to a good renderer? I would love to play around with them.

I like the beauty/fractality of these mandelbulbs, but if anyone finds the holy grail of the 3D M-set (you might be there you think?), I will be there rendering them ;)
and yes my images are mostly of the power 8 White/Nylander type. (-sin, sin and cos variations).

J


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: KRAFTWERK on May 31, 2010, 04:47:32 PM
Hi and sorry if I'm interrupting a specific project here.  This is something different.  I've been having a dialogue principally with Jehovajah in "...search for the holy grail continues..." section, and am convinced there is an implementation problem for one approach to M in extended Dims.  I'd love to get more to look at the ideas I'm trying to communicate there. Taken together, the messages I left are enough to duplicate my 2-d results and judge whether a 3-d generator for it exists or can be written easily.  My comments begin on page 12 and continue to the present.  Would love to show some pix, make a paper available, and provide my formula files for this in FractInt.  Someone please advise.

You should try Subblues pixelbender-script (that is the renderer I use).
It is possible to change the formulas in the script, so you might be able to implement your new formulas in it.
Pixelbender is a free Adobe-app (Win&Mac), you can download it here:
http://www.adobe.com/devnet/pixelbender/

Subblues script for it is here:
http://www.subblue.com/projects/mandelbulb

I hope this helps!

J


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on May 31, 2010, 08:24:59 PM
K- Wow, so fast!  Not used to that.  If I could upload the stuff mentioned, you'd see it's no more complicated than the math principles that gave us complex nos. in the first place. (Honest!) But I do need to do that still.  I'm a babe in the woods when it comes to telecommunications, oddly enuf, so I need that kind of patience!  Anyway, don't know if I'm missing something, but I haven't found anything in "help" here about how to do that.  Thanx!

Didn't realize this thread spilled onto a second page already.  Went to pixel bender, and it's like learning another language, "easier than C++", but it looks nearly as involved.  In the bad old days, I did this stuff in BASIC.  Miserably slow by today's standards.  If I was to invest that kind of time, + I think I will eventually have to break down and do that, I'd go to C++ for versatility in other areas.  Still, I see the results.  Neat!  Another issue w me is having witnessed the evolution of fractal art obscuring the basic math for those inclined to understand it.  I would never ever do that, having been too frustrated over the years w people who seem to go out of their way to make things hard to grasp.  It may be formality, but it presents hurdles unnecessarily, in my humble opinion.  If something could be made plainer, it ought to be.


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: KRAFTWERK on June 01, 2010, 08:48:57 AM
Going a bit off topic here I guess... But I share your interest in the basics of fractals, the plain mandelbrot set is for me far more beautiful than much of the "fractal art" some people call fractal...

That is why I try to do plain mandelbulbs (with some experimental exceptions ;) ) And look forward to the next step closer to the "real" 3D mandelbrot.

Keep on searching fracmonk! I hope you find a tool that suits you, I'd love to see some renderings!


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on June 01, 2010, 02:37:32 PM
K- I can't see how it's off-topic at all.  As far as I can see, this is the basic M in an extension environment that is meaningful to both the mathematics of complex numbers and the the famous function we have come to love.  That 2-d slice that Dr. M came up with circa 1980 just happens to have its characteristics because the set of complex nos. is the smallest CLOSED set of 2^n dimensions (n being a pos integer).  But we can look at it from other helpful points of view.  My "grail" has been to provide new insights for others with greater skill and understanding of the MLC conjecture and the very concept of local connectedness than I have.  From what I've read, even Dr. M himself has trouble with the distinction between M's simple connectedness and the possibility of its local connectedness.  I must leave it to people who have reason to believe they have a deeper grasp of the topological distinction, if any truly exists.

Now THAT's off-topic!  But it's still relevant, as mathematics is supposed to seek truth.

ON topic: So far, the .frm file for FractInt I left in the "grail" thread is a good 2-d implementation, and if no existing prog can display it in more dims, one would have to be made.  (If it means that much to anyone- I think it's important in ways others don't yet see) Give that paper a read, and you'll see what I mean.  To understand the underlying math is well worth the effort.


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on June 02, 2010, 01:14:51 PM
Having the luxury currently to look around a little bit, if implementation means finer points of using existing progs, this deal should move to "programming" section properly.  Yes?  No?

Still think it's worthy of more eyes upon it.  Also, I might add that proper overviews of a multidimensional object require enormous numbers of pictures (for instance, 4 x 3-d ANIMATIONS with undisplayed 4th dimension as the frame-by-frame (time increments) in this 4-d case) to do them justice, and I don't want to hog space, even w 2-d renderings.  Besides, d.i.y. is very fulfilling.  "Use the formula file, Luke!" said Obi... (before anyone jumps to conclusions, I'm not a big StarWars fan, but the quote seemed fitting)  Be well!


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: KRAFTWERK on June 02, 2010, 01:19:01 PM
(for instance, 4 x 3-d ANIMATIONS with undisplayed 4th dimension as the frame-by-frame (time increments) in this 4-d case) to do them justice...

That sounds inqredible interesting, I hope someone here with the knowledge will do that some day!

I downloaded your paper, will see if I can grasp it...   O0


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on June 03, 2010, 03:24:18 AM
K- Happy to hear that.  Please critique on clarity if you will.  I wanted it to be as easy to follow as possible.  Thanx!  And of course, if you need further explanation, there are no stupid questions...


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on June 04, 2010, 03:36:30 AM
Here are 2-d's with other two dims=0 as basics which would call up the right formula files in FractInt to zoom or change param settings, here and in the previous post (modified, and if it works...)

In last post, the first will be very familiar.  The rest will recombine dimensions, this one w that one, taking turns.  With 4-d objects, taking turns is the thing, since it's just not visible all at once, or displayable all at once, but curiously, all dimensions can be combined seamlessly just the same (as long as they...take their turns...)  At first glance, not terribly exciting, but you 3-d ray-tracer types can cure all that!


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on June 11, 2010, 12:43:20 PM
I may have misled some of you w the last 2 posts a bit.  The pix need the .frm file that made them, which can be found in the "search for the holy grail continues" thread.  It must be present to do any changes to them.  Sorry if I caused any undue frustration.

There was a glitch in the code that made these, found only yesterday (11-11-10).  The correct code for the right images, a bit different, can be found at post 251 in the aforementioned thread.


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: jehovajah on July 01, 2010, 09:13:27 AM
@Fracmonk, now i see your pics i am fairly convinced that Quasz has it right. When i get time i will render the variation using the k unit vector to see if it matches the other 3 images you have produced.

The problem as always is one of perspective and technique and settings. The 3d view has to make certain assumption to compute a surface,and then to colour it. David Makin i am sure can take you through the theory of that, but it means that an object can look very different in renders with different settings: thus the mandelbrotp settings are closer to what you are getting than the mandelbrot settings, in Quasz that is. Good luck and good fortune!


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: fracmonk on July 02, 2010, 06:42:00 PM
J- Kinda heard that before, but never saw a silhouette that matched unequivocally yet.  Saw some slick (OK, really slick) pix in gallery showing very impressive 3d stuff- lighting, colors, intonations, etc.  I'm afraid most are too hypnotized with polish to pay much attention to the math anymore.  I mentioned at the "grail" thread how i'd kinda like to see someone try it my way, duplicate my results, and do their own survey in 2-d before evaluating whether QuasZ can really do it.  If it could, I'd buy it!  But to be honest, in a perfect world, the math behind these pix should have showed up before quaternions did.  The world, however, is never that way, is it? 


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: Alef on December 08, 2011, 04:27:52 PM
Well, continiuing with http://www.fractalforums.com/3d-fractal-generation/true-3d-mandlebrot-type-fractal/ (http://www.fractalforums.com/3d-fractal-generation/true-3d-mandlebrot-type-fractal/) I was trying to implement true mandelbrot in 3D.

I think, mandelbrot set is generated becouse in complex numbers x^2 = real^2 >< y^2 = i^2. So mandelbrot set is property of numbers themselves and not of the simple formula z=z^2+c.

In quaternion numbers still x^2 >< y^2. But I think z^2 = j^2     =    y^2 = i^2. So correct z^2  allways will be eather x^2 or y^2 or n*y^2. Square have just two posibilities + or -. So by having equal values at z and y axis it generate rotation surface. Unless numbers are being manipulated so that x >< y >< z ;)

But if you iterate:
z= quaternion ( real(z) , imag(z), part_j(z)+ part_k(z), part_k(z) - part_j(z) );
z= z*z+C;

It still have features of rotation surface / being extruded but it gained fractal features in z axis and zooming in reveals more features. In 2D it generates unaltered mandelbrot set. j+k and k-j are just try and error...

However, there would be matematicaly corect 3D Mandelbrot set, probably it woun't reveal so nice images as mandelbulbs, since tentacles would go in all direction, creating chaos;)


Title: Re: Implementation: 3D mandelbrot type fractal
Post by: ironfractal on August 21, 2016, 12:13:13 AM
that one is my favorite fractal I all so like IfS types to  :cantor_dance: :peacock: