News: Support us via Flattr FLATTR Link

 Pages: 1 ... 32 33 [34]   Go Down
 Author Topic: True 3D mandelbrot type fractal  (Read 338607 times) Description: 0 Members and 1 Guest are viewing this topic.
fractalrebel
Fractal Lover

Posts: 211

 « Reply #495 on: November 19, 2009, 07:37:53 PM »

For those of you interested in rendering the Mandelbulbs and corresponding Juliabulbs in UltraFractal 5, I have just updated the UF database with my latest changes to 3DFractalRaytrace and the plugins for the Mandelbulb and the Juliabulb. I have gotten my gradient function working correctly for the two plugins, which really involved gettiang the correct derivative functions.
 Logged

kram1032
Fractal Senior

Posts: 1762

 « Reply #496 on: November 19, 2009, 07:58:12 PM »

@JosLeys

Spherical Coordinates are 3D. You need only two values to get to any point on the surface. But if you want to have a not-fixed radius (which is the case, here), you have your third dimension

Maybe, try to rotate in 4D-style? That might give some nice results...
Though, if you go for 4D, maybe you find a way to unify julia with Mandelbrot (not in the Buddhagram way^^) - that probably will lead to more interesting details, as no artifical extension way has to be done then...

Also, omitting one axis probably might not be the best way... what's about a full 4D -> 2D projection? (Or is that equivalent to dropping an axis?)

As said before, doing that direct conversion from 2D to 3D seems a bit odd...
The Mset lies inside an algebratic vector-space, where new calculation rules apply, which results in that nice shape.
Adding just another axis which does the very same as the second axis, where no correspondance is between the two axes, whill likely destroy details. (Especially on the M²-Set, as that doesn't even have radial symmetries)

In a true extension, all axes would comunicate with each other, I guess...
Quaternionic has the "problem" of 2*4D, rather than the 2*2D in Complex numbers (2* because there are the two real and the two imaginary parts)

Maybe, we could try to develop a small algebra just for that...

for instance...

x*x=-x
y*y=-y
z*z=-z
x*y=z
y*z=x
x*z=y
x*y*z=0

that would be the simplest case I can think of.... (a*b*c=0 to avoid a fourth Dimension being formed,  a, b and c are axial units like i,j and k with the quaternions)

Of course, it's very likely, that this algebra wouldn't hold under any conditions, but for a Mandelbrot-Set, it should be possible to work with

x,y,z are the units from above...

(n*x+k*y+j*z)²+a*x+b*y+c*z =

j²*z^2+2*j*k*y*z+2*j*n*x*z+k^2*y^2+2*k*n*x*y+n^2*x^2*+a*x+b*y+c*z=

-j²z + 2*j*k*x + 2*j*n*y -k²y + 2*k*n*z -n²x + a*x + b*y + c*z

split into the three parts:

nx -> (-n²+2jk+a)x
ky -> (-k²+2jn+b)y
jz -> (-k²+2kn+c)z

not actually toooo hard formulae... they seem to be closely related to the imaginary part of the Mandelbrot, though. If I'm unlucky, this will nearly look like the quaternion variant...

As long as no exponential or stuff is needed, which you'd first have to figure out, this algebra should hold easily...

for instance, x*x*y*z*z*z=x²*y*z³=-x*y*-z*z=-x*y*-(z²)=-x*y*z=0
xn=
x | n is an odd
-x | n is an even

scalars in front of the units simply get extended with the very same rules as always...
 Logged
cbuchner1
Fractal Phenom

Posts: 443

 « Reply #497 on: November 19, 2009, 09:30:48 PM »

I've tried power of 27, but that starts looking more and more like a ball.

So here's a power of 5, rendered on my GPU in phong shading.

 power5.JPG (70.66 KB, 648x512 - viewed 2464 times.) Logged
fractalrebel
Fractal Lover

Posts: 211

 « Reply #498 on: November 19, 2009, 10:05:18 PM »

Something doesn't look quite right here. Maybe it's your rotation angle(s), but I don't think so. Here is my version of z^5 + c:
 Mandel5.jpg (128.64 KB, 640x640 - viewed 2398 times.) Logged

David Makin
Global Moderator
Fractal Senior

Posts: 2283

 « Reply #499 on: November 19, 2009, 10:24:53 PM »

I've tried power of 27, but that starts looking more and more like a ball.

So here's a power of 5, rendered on my GPU in phong shading.

Looks like gross over-stepping in the ray-marching ?
 Logged

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

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

Posts: 443

 « Reply #500 on: November 19, 2009, 10:28:03 PM »

Hmm, so far my power 8 looked pretty much like anyone else's.

Here's my entire distance estimator in plain CUDA-C. A float3 is a vector with elements .x, .y, and .z.
x is the float3 vector with the current coordinate on the ray (elements x.x, x.y, x.z) - poor naming, I know.
I am using the trigonometric version (polar coordinates mostly). Let me know if something smells fishy.

Code:
float R  = sqrtf(x.x*x.x + x.y*x.y + x.z*x.z);
float th = atan2(x.y, x.x);
float ph = atan2(x.z, sqrtf(x.x*x.x + x.y*x.y));

float3 dz;
const float c = 1.0f;
dz.x = 1.0f;
dz.y = 0.0f;
dz.z = 0.0f;
float ph_dz = 0.0f;
float th_dz = 0.0f;
float R_dz  = 1.0f;

const float sq_threshold = 4.0f;   // divergence threshold

// Iterate to compute the distance estimator.
int i = m_max_iterations;

const float p = power;             // power of fractal
while( i-- )
{
// derivative
dz.x = p*powf(R, p-1.0f) * R_dz*cosf(ph_dz+(p-1.0f)*ph)*cos(th_dz+(p-1.0f)*th)+c;
dz.y = p*powf(R, p-1.0f) * R_dz*cosf(ph_dz+(p-1.0f)*ph)*sin(th_dz+(p-1.0f)*th);
dz.z = p*powf(R, p-1.0f) * R_dz*sinf(ph_dz+(p-1.0f)*ph                       );

R_dz  = sqrtf(dz.x*dz.x + dz.y*dz.y + dz.z*dz.z);
th_dz = atan2(dz.y, dz.x);
ph_dz = acos(dz.z/R_dz);

// new x,y,z coordinate
x.x = powf(R, p) * cosf(p*ph)*cos(p*th) + x.x;
x.y = powf(R, p) * cosf(p*ph)*sin(p*th) + x.y;
x.z = powf(R, p) * sinf(p*ph)           + x.z;

R  = sqrtf(x.x*x.x + x.y*x.y + x.z*x.z);
th = atan2(x.y, x.x);
ph = atan2(x.z, sqrtf(x.x*x.x + x.y*x.y));

// Stop when we know the point diverges.
if( R > sq_threshold )
break;
}
return  0.5 * R * logf(R)/R_dz;
 « Last Edit: November 19, 2009, 10:34:22 PM by cbuchner1 » Logged
David Makin
Global Moderator
Fractal Senior

Posts: 2283

 « Reply #501 on: November 19, 2009, 10:52:20 PM »

Hmm, so far my power 8 looked pretty much like anyone else's.
Here's my entire distance estimator in plain CUDA-C. A float3 is a vector with elements .x, .y, and .z.
x is the float3 vector with the current coordinate on the ray (elements x.x, x.y, x.z) - poor naming, I know.
I am using the trigonometric version (polar coordinates mostly). Let me know if something smells fishy.

This is wrong:

ph_dz = acos(dz.z/R_dz);

Change to:

ph_dz = asin(dz.z/R_dz);

Also this is correct:

ph = atan2(x.z, sqrtf(x.x*x.x + x.y*x.y));

but this is quicker:

ph = asin(x.z, R);

Also it's not causing the main problem but the distance estimate will be considerably more accurate if you increase the allowed bailout to say 11 or more (I have testing R^2 against 128 as the minimum option in my UF formula).

In addition, although I don't know CUDA, I'd guess that precomputing the sines and cosines will be considerably faster than calling sin() and cos() twice with the same argument - also does CUDA not have a sincos() function ?

 « Last Edit: November 19, 2009, 11:01:16 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
cbuchner1
Fractal Phenom

Posts: 443

 « Reply #502 on: November 19, 2009, 11:17:02 PM »

Thanks for the corrections.

My power 5 looks less mutant now. And some other weird effects (such as banding effects in flat surface regions) are gone. In addition to the errors you found, I was not adding a constant c vector in each iteration - instead I was adding the current x vector in some kind of recursive feedback loop. I am surprised it even gave sane images.

Here's the cleaned up code where I also renamed x to z.

Code:
float R  = sqrtf(z.x*z.x + z.y*z.y + z.z*z.z);
float th = atan2(z.y, z.x);
float ph = asinf(z.z / R);

float3 dz;
const float3 c = z;
float ph_dz = 0.0f;
float th_dz = 0.0f;
float R_dz  = 1.0f;

const float sq_threshold = 4.0f;   // divergence threshold

// Iterate to compute the distance estimator.
int i = m_max_iterations;

const float p = power;             // power of fractal
while( i-- )
{
// derivative
dz.x = p*powf(R, p-1.0f) * R_dz*cosf(ph_dz+(p-1.0f)*ph)*cos(th_dz+(p-1.0f)*th)+1.0f;
dz.y = p*powf(R, p-1.0f) * R_dz*cosf(ph_dz+(p-1.0f)*ph)*sin(th_dz+(p-1.0f)*th);
dz.z = p*powf(R, p-1.0f) * R_dz*sinf(ph_dz+(p-1.0f)*ph                       );

R_dz  = sqrtf(dz.x*dz.x + dz.y*dz.y + dz.z*dz.z);
th_dz = atan2(dz.y, dz.x);
ph_dz = asinf(dz.z/R_dz);

// new x,y,z coordinate
z.x = powf(R, p) * cosf(p*ph)*cos(p*th) + c.x;
z.y = powf(R, p) * cosf(p*ph)*sin(p*th) + c.y;
z.z = powf(R, p) * sinf(p*ph)           + c.z;

R  = sqrtf(z.x*z.x + z.y*z.y + z.z*z.z);
th = atan2(z.y, z.x);
ph = asinf(z.z / R);

// Stop when we know the point diverges.
if( R > sq_threshold )
break;
}
return  0.5 * R * logf(R)/R_dz;

And finally after optimization (sincosf etc...) the computation part looks like this:

// derivative dz iteration
float pP_ = p*powf(R, p-1.0f);
float c1, s1;   sincosf(ph_dz+(p-1.0f)*ph, &s1, &c1);
float s1_, c1_; sincosf(th_dz+(p-1.0f)*th, &s1_, &c1_);
dz.x = pP_ * R_dz*c1*c1_+1.0f;
dz.y = pP_ * R_dz*c1*s1_;
dz.z = pP_ * R_dz*s1;

// polar coordinates of derivative dz
R_dz  = sqrtf(dz.x*dz.x + dz.y*dz.y + dz.z*dz.z);
th_dz = atan2(dz.y, dz.x);
ph_dz = asinf(dz.z /R_dz);

// z iteration
float P_ = powf(R, p);
float s2,c2;    sincosf(p*ph, &s2, &c2);
float s2_, c2_; sincosf(p*th, &s2_, &c2_);
z.x = P_ * c2*c2_ + c.x;
z.y = P_ * c2*s2_ + c.y;
z.z = P_ * s2    + c.z;

// polar coordinates of z
R  = sqrtf(z.x*z.x + z.y*z.y + z.z*z.z);
th = atan2(z.y, z.x);
ph = asinf(z.z / R);

 « Last Edit: November 19, 2009, 11:33:59 PM by cbuchner1 » Logged
David Makin
Global Moderator
Fractal Senior

Posts: 2283

 « Reply #503 on: November 19, 2009, 11:19:42 PM »

 Logged

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

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
shanest
Guest
 « Reply #504 on: November 19, 2009, 11:22:26 PM »

Hello,

I just found this thread in the last couple of days because of the publicity of twinbee's Mandelbulb article.

At anyrate, I'd love to get in and dabble with this stuff myself.  I have pretty strong background in both Math and programming, but haven't experimented with fractals since playing around in Mathematica 5 years ago and have never done much graphics-based programming.

What is the best way to get started with this?  In particular, how would I write something like twinbee's custom raymarcher?  Those images are absolutely beautiful.

In general, I'd prefer to know of solutions that are free/open-source and cross-platform (Linux is my standard OS) besides Xaos.  I'm not adverse to trying to write something on my own, but basically just want to get exploring in the easiest way possible.

The easiest free route to anything fractal where you want to write your own formulas is probably ChaosPro:

http://www.chaospro.de/

Though as with Ultra Fractal this will not produce the fastest possible routines since that's always going to be better coded directly in C/C++ etc. or better still for a GPU (if you've got good cooling)

If you want to try in ChaosPro my UF formula here:

http://www.fractalgallery.co.uk/MMFWip3D.zip

includes many of the formulas discussed in this thread using basic Phong rendering and is fairly easily adaptable to work in ChaosPro - just remove all references to the use of the fBm (to get the formula from the zip, download & install the trial version of UF5, run it and "Update Public Formulas" from the Options menu, unzip the above file, copy all the text from the txt file and then paste into the open fractal window in UF5. Then when the parameter file has pasted click on the edit formula button (top right)  and you then have the text source for the UF fornula which you can transfer/adapt to ChaosPro.

Arrgh - apologies, I missed that you said "cross-platform" and Linux

For now, I'm running UF5 under WINE and it appears to work well.

I can't, however, figure out how to get your 3D code or the 3DRaytracerFormula plugin.

I've updated the public forums, but if I paste the text into the "Open Fractal" window, the program just crashes on me.

What's the easiest way to get your renderer up and running?  I'd love to explore this construction and make some changes myself.
 Logged
David Makin
Global Moderator
Fractal Senior

Posts: 2283

 « Reply #505 on: November 19, 2009, 11:33:28 PM »

In addition to the errors you found, I was not adding a constant c vector in each iteration - instead I was adding the current x vector in some kind of recursive feedback loop. I am surprised it even gave sane images.

I missed that (I never thought to check the constant), glad it seems to be fixed now.

Another point - if you make the +1.0f in the iterated derivative into a passed parameter of either 0 or 1 then you have a routine that works for Mandelbrots (1) or Julias (0).

I don't suppose an ATI X600 or even an ATI X1900XT are CUDA-enabled ?
 « Last Edit: November 19, 2009, 11:41:49 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
cKleinhuis
Fractal Senior

Posts: 6957

formerly known as 'Trifox'

 « Reply #506 on: November 19, 2009, 11:56:16 PM »

This topic has been locked because the main thread theme has reached some kind of a result, and is simply far to big now

further discussion about the formula and renderings, or implementation details should from now on be discussed in the dedicated boards:

general discussion should take place at
http://www.fractalforums.com/the-3d-mandelbulb/

implementation details or further details about the formula
http://www.fractalforums.com/mandelbulb-implementation/

further modifications of the formula, or the formula itself should be discussed here:
http://www.fractalforums.com/theory/

impressions from implemented formulas can be showed of there
http://www.fractalforums.com/mandelbulb-renderings/

well done people!

 « Last Edit: November 19, 2009, 11:59:49 PM by Trifox » Logged

---

divide and conquer - iterate and rule - chaos is No random!
 Pages: 1 ... 32 33 [34]   Go Down