• September 26, 2022, 12:44:55 PM

Author Topic:  Baguabox formula implementation in M3D  (Read 1112 times)

0 Members and 1 Guest are viewing this topic.

Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Baguabox formula implementation in M3D
« on: October 04, 2018, 12:12:19 PM »
I tried to implement in M3D JIT formula which worked quite OK in ChaosPro. The formula originaly was intended as amazing box but realy it is different from any other fractals. 
Bagua, becouse it sometimes generated octagonal shapes like thing on the South Korea flag.

I decided to implement in Mandelbulb3D this formula becouse when I did google search of my DeviantArt Mandelbulb3D images (it's like google based top 10) I noticed that my old ChaosPro baguabox renders still are in the top. Alsou this formula is fun to play around.


Baguabox formula with small tutorial, explanation and sample parameters are in the attachment. I did it in 2 versions, one simple and easy to use, and other slower with lots of changable parameters and additional functions like "Lp spaces" and "unit vector addition" and then added positive fold baguabox which can generate chessboards.


Formula can alsou could be downloaded from Deviantart stash https://sta.sh/0r09kpugop7

Linkback: https://fractalforums.org/index.php?topic=1953.0
« Last Edit: October 04, 2018, 12:54:14 PM by Alef »
by Edgar Malinovsky aka Edgars Malinovskis.

Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Re: Baguabox formula implementation in M3D
« Reply #1 on: October 04, 2018, 01:02:46 PM »
Programming.

DE based raymarcher is not the best for this formula. It is not analytical so derivatives - DE can't fully predict formula growth.

Well, Darkbeam once mentioned discontinuities destroying DE function.
It have some problems with DE but it is mostly a matter of parameter tuning (internal parameter .DEScale = 0.0105 works OK; Mandelbulbs have .DEScale = 1, for boxes works = 0.5, and for some brots = 2 or 4) and it required unusual bailout value (= 4, 6 or more but not the default 16).
 
It have a bitt of "sand" - noise. With larger "DE stop" value it dissapears but fractal becomes solid.
Minimisation of ".DEScale" even more improves quality but I think it have one bad side efect. If you increase image size by x2 it will alsou increase "DE stop" x2 and the fractal will become mutch thicker. Probably this internal variable non-lineary interacts with scale and "DE stop".
On another hand DE noise could look as sandstone texture. What is nice for plastic 3D.

This is not too problematic. viewing 1:2 can do miracles.


It takes just single transformation to generate this fractal Zvector=baguafold(Zvector) + C. 

Code: [Select]
//Baguafold, easy to understand code:
//Zvector(zx,zy,zz)
// lenght, add - parameters

modulus =sqrt(sqr(zx) + sqr(zy)+ sqr(zz))

if (zx > lenght)
{
zx=-zx/modulus -add;
}
else if (zx < -lenght)
{
zx=-zx/modulus +add;
}

if (zy > lenght)
{
zy=-zy/modulus -add;
}
else if (zy < -lenght)
{
zy=-zy/modulus +add;
}

if (zz > lenght)
{
zz=-zz/modulus -add;
}
else if (zz < -lenght)
{
zz=-zz/modulus +add;
}

It isn't a fold. Transformation turns Z vector outside of defined area into negative of it's unit vector + Add. (Unit vector - vector of same orientation but of the lenght = 1.) With +C this is enought for fractal behaviour.

On X axis on positive side with lenght =2 this would be:
if X > 2 then X=-1; X=X+Xstart
Xstart = 1 will loop forever: 1, 2, 3, -1, 0, 1, 2, 3, -1, ....

Code: [Select]
//Mandelbulb3D JIT code, optimised:

modulus  := sqrt( x*x + y*y + z*z);

negativeX := -x;
negativeY := -y;
negativeZ := -z;

 // to awoyd division / 0; Not necessary in M3D but still benefitial
 if modulus = 0 then
    begin
      modulus := 1e-15;
   end;

if x > Lenght then
    begin
x := negativeX/modulus - AddValue;
    end
  else if negativeX > Lenght then
    begin
x := negativeX/modulus + AddValue;
   end
  else
    begin
//walk along
    end;

if y > Lenght then
    begin
y := negativeY/modulus - AddValue;
    end
  else if negativeY > Lenght then
    begin
y := negativeY/modulus + AddValue;
   end
  else
    begin
//walk along
    end;

if z > Lenght then
    begin
z := negativeZ/modulus - AddValue;
    end
  else if negativeZ > Lenght then
    begin
z := negativeZ/modulus + AddValue;
   end
  else
    begin
//walk along
    end;

  x := x*scale + PIteration3D^.J1;
  y := y*scale + PIteration3D^.J2;
  z := z*scale + PIteration3D^.J3;


Positive baguafold. Here it turns Zvector outside of certain area into it's unit vector.
Xstart = 1 will loop forever: 1, 2, 3, 1, 2, 3, 1, ....

Code: [Select]
modulus  := sqrt( x*x + y*y + z*z);

//baguafold, positive version

//optimisation for speed
negativeLenght:= -Lenght;


 // to awoyd division / 0; Not necessary in M3D but still benefitial
 if modulus = 0 then
    begin
      modulus := 1e-15;
   end;




///=========x==========================
if x > Lenght then
    begin
x := x/modulus + AddValue;
    end
  else if x < negativeLenght then
    begin
x := x/modulus - AddValue;
   end
  else
    begin
//walk along
    end;

///=========y==========================
if y > Lenght then
    begin
y := y/modulus + AddValue;
    end
  else if y < negativeLenght then
    begin
y := y/modulus - AddValue;
   end
  else
    begin
//walk along
    end;

///=========z==========================
if x > Lenght then
    begin
z := z/modulus + AddValue;
    end
  else if z < negativeLenght then
    begin
z := z/modulus - AddValue;
   end
  else
    begin
//walk along
    end;


X/0
Mandelbulb3D like other fractal programms allows of N/0. But the conditional eliminating division by 0 seems to increase render speed. It took off some 0.7 secunds on 2 minutes, but the PC is quite old. Not mutch, but just putting conditional into executable must decrease render speed.



I think Mandelbulb3D JIT compiler is slower than ChaosPro compiler.


QUESTION:
What is PIteration3D^.J? If J = 1,2,3 it is Cx, Cy, Cz. But do this thing have some other variables like zOld or iteration number?

p.s.
For non users of Mandelbulb3D. JIT formulas can be read in notepad as .txt file.


Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Re: Baguabox formula implementation in M3D
« Reply #2 on: October 04, 2018, 01:12:20 PM »
« Last Edit: October 05, 2018, 09:29:34 AM by Alef »

Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Re: Baguabox formula implementation in M3D
« Reply #3 on: October 05, 2018, 09:35:56 AM »
Re rendered example parameter, Now itš slightly more beautifull.


Alsou this image. It isn't particulary beautifull, but ilustrates basic pattern well. Add = 0.4, Lenght = 1.8, Lp_space=4


Alsou some images from Chaos pro is in deviant art. Withou DE surfaces are absolutely smooth: https://www.deviantart.com/edo555/gallery/40308787/Baguabox

Offline mclarekin

  • 3e
  • *****
  • Posts: 1037
Re: Baguabox formula implementation in M3D
« Reply #4 on: October 05, 2018, 11:13:09 PM »
I think i remember this as a transform in M3D. The problem is that it is discontinuous and chops up the fractal, therefore analytic DE will be bad at  the cuts. I coded it up in Fragmentarium with analytic DE but I had a weird problem. I may re-test later in Mandelbulberv2.

 anyhow this what the function looks like using "sign" which you should be able to use in JIT

Code: [Select]

vec3 AbsZ = abs(z);
//AbsZ.x = abs(z.x);
//AbsZ.y = abs(z.y);
//AbsZ.z = abs(z.z);

if (AbsZ.x > limit) z.x = -sign(z.x) * ( AbsZ.x / r + Offset.x);
if (AbsZ.y > limit) z.y = -sign(z.y) * ( AbsZ.y / r + Offset.y);
if (AbsZ.z > limit) z.z = -sign(z.z) * ( AbsZ.z / r + Offset.z);
« Last Edit: October 06, 2018, 12:38:24 AM by mclarekin, Reason: fixed code »

Offline Sabine62

  • 3f
  • ******
  • Posts: 1379
  • It's just a jump to the left...
    • sabine62.deviantart.com
Re: Baguabox formula implementation in M3D
« Reply #5 on: October 06, 2018, 04:29:53 AM »
Had a go at the JIT-formula in mb3d, but must agree with mclarekin: it seems to have some problems: lots of cuts mainly and loads of floating artefacts. I've tried hybridation, adding transforms etc., but the cuts remain really prominent...
To thine own self be true

Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Re: Baguabox formula implementation in M3D
« Reply #6 on: October 06, 2018, 01:07:15 PM »
Yes, it just don't go well with DE based raymarcher. Realy it's a suprise that it works (with some tweaking DE parameters). On increasing DE the noise seems to dissapear but then it becomes featurless. So I used 1:2 antialiasing.

Chaos Pro uses completely different approach. It uses brute force raymarcher and then optimises number of calculated rays. Chaos pro was released before De was invented;) Byt there were some non-DE in fragmentarium for DE non friendly formulas.

I realy hadn't tested how it hybridises. M3D allways switches to default bailout value on changeing formulas, what makes it one hudge solid.

In JIT readme there are no mention of sign function. But in it's readmy there are no mention of trunc or floor functions, and they are present. Calculation with sign must be more optimal - faster.

I recieved a reply from The Programmer of M3D:
Quote
Hi, the original comment in this is:
TIteration3Dext =
  ...
  C1, C2, C3: Double;     //0     input start values before 4d rotation, C4 is 0.  Do Not Change!
   J1, J2, J3: Double;     //+24   julia start values or the pixelpos, these are the constants to add
   J4:         Double;     //-56   4d extension         FastMove(dJUx, It3Dex.J1, 168);
Now I need to decipher what it is.
« Last Edit: October 06, 2018, 01:36:35 PM by Alef »

Offline mclarekin

  • 3e
  • *****
  • Posts: 1037
Re: Baguabox formula implementation in M3D
« Reply #7 on: October 06, 2018, 11:32:19 PM »
These the possible "c" values     of z = fn(z) +c


  C1, C2, C3: original value of point being iterated (p.xyz and C4 =p.w = 0.0)
   J1, J2, J3: julia.xyz    and you can include J4 (julia.w)  for 4D

I am assuming they are the allowable extentions  ot PIteration3D^

ie  PIteration3D^.C1


You can test my assumption by adding a code   x := x+ PIteration3D^.C1; and see if the JIT compiler will accept it.

Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Re: Baguabox formula implementation in M3D
« Reply #8 on: October 08, 2018, 12:20:55 PM »
Then for most of formulas they should be just simmilar, C1 ... 2,3 just is not needed. Compiler do not accept sign(x).

Offline Kalter Rauch

  • Fractal Feline
  • **
  • Posts: 197
Re: Baguabox formula implementation in M3D
« Reply #9 on: November 16, 2018, 07:32:10 PM »
Here's a ChaosPro Baguabox Inversion with GIMP Cellular Noise background...


« Last Edit: November 16, 2018, 07:43:17 PM by Kalter Rauch »

Offline Alef

  • 3c
  • ***
  • Posts: 829
  • a catalisator / z=z*sinh(z)-c^2
    • My deviant art page
Re: Baguabox formula implementation in M3D
« Reply #10 on: November 20, 2018, 04:53:00 PM »
Nice. Especialy a Cellular Noise background  :thumbs:

I did few MC renders of baguabox formula based scenery. The formula works better in Monte Carlo method then in standart render. In Fragmentarium it would require BruteForceRaytracer not analytical DE (as of in Mandelbulb3D )

I alsou noticed that all the MC parameters are saved alsou in M3D parameters. MC render uses few additional parameters, which survives transfer to main renderer.






xx
M3d version 1.9.9.33 refusing to save images

Started by chaos_crystal on Mandelbulb3d

1 Replies
422 Views
Last post November 27, 2020, 10:18:24 AM
by Sabine62
xx
M3D or Mandelbulber for Linux?

Started by IvoHristov on Fractal Programs Discussion, Help, & Support

2 Replies
1475 Views
Last post August 30, 2020, 01:48:20 AM
by batjorge
xx
_Asdam_transform in M3d

Started by dankje on Noob's Corner

4 Replies
156 Views
Last post March 10, 2022, 05:35:10 PM
by Alef
sad
M3D, v 1.9.9, I see Asian characters on some menus.

Started by quasihedron on Mandelbulb3d

2 Replies
531 Views
Last post May 05, 2018, 03:13:30 AM
by 1Maniac
xx
M3D Processor Benchmarks

Started by Fitz on Mandelbulb3d

5 Replies
753 Views
Last post October 25, 2018, 06:16:44 PM
by Sabine62