## The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!

 Pages: [1] 2   Go Down
 Author Topic: Implementation: 3D mandelbrot type fractal  (Read 43888 times) Description: 0 Members and 1 Guest are viewing this topic.
steamraven
Guest
 « 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 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?

 « Last Edit: November 20, 2009, 06:18:48 PM by steamraven, Reason: Add link to david\'s DE » Logged
cKleinhuis
Fractal Senior

Posts: 7044

formerly known as 'Trifox'

 « Reply #1 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
 Logged

---

divide and conquer - iterate and rule - chaos is No random!
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #2 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?

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.

 « Last Edit: November 18, 2009, 11:41:05 PM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
lycium
Fractal Supremo

Posts: 1158

 « Reply #3 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.
 Logged

David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #4 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).
 « Last Edit: November 20, 2009, 01:40:20 AM by David Makin » Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
steamraven
Guest
 « Reply #5 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,
 Logged
David Makin
Global Moderator
Fractal Senior

Posts: 2286

 « Reply #6 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,

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

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
steamraven
Guest
 « Reply #7 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.
 « Last Edit: November 24, 2009, 05:30:35 PM by steamraven » Logged
ddrcoder
Forums Newbie

Posts: 1

 « Reply #8 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.

 Logged
Snakehand
Guest
 « Reply #9 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:

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

 Logged
KRAFTWERK
Global Moderator
Fractal Senior

Posts: 1439

Virtual Surreality

 « Reply #10 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:

<Quoted Image Removed>

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
 Logged

fracmonk
Fractal Fertilizer

Posts: 356

 « Reply #11 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.
 Logged
KRAFTWERK
Global Moderator
Fractal Senior

Posts: 1439

Virtual Surreality

 « Reply #12 on: May 31, 2010, 10:42:08 AM »

No worry fracmonc, I have found what I was looking for!
 Logged

fracmonk
Fractal Fertilizer

Posts: 356

 « Reply #13 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?
 Logged
KRAFTWERK
Global Moderator
Fractal Senior

Posts: 1439

Virtual Surreality

 « Reply #14 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.
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
 Logged

 Pages: [1] 2   Go Down