Welcome to Fractal Forums

Fractal Software => Mandelbulber => Topic started by: freakiebeat on December 09, 2016, 12:30:39 AM




Title: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: freakiebeat on December 09, 2016, 12:30:39 AM
I am currently working with mandelbulber v2.09, and looking for any formulas or transforms that provide the functionalities of _polyfold_sym and polyfoldsymIFS from mb3d. Can anyone provide me with the formula/transform name(s), or is this not yet implemented in v2?


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 10, 2016, 02:40:48 AM
Not implemented yet. There are sooooo many to implement. I will put these on my TODO list.


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: DarkBeam on December 10, 2016, 09:04:39 AM
Found this in old pms. Sent by the user alexl:
void Poly_Fold(inout dvec4 p, float order)
{
   float m = order/TWOPI;

   float angle = round(m*(-atan(float(p.x),float(p.y))))/m;

   p.xy=rotate(p.xy,angle);
}

void Poly_Fold_xz(inout dvec4 p, float order)
{
   float m = order/TWOPI;

   float angle = round(m*(-atan(float(p.x),float(p.z))))/m;

   p.xz=rotate(p.xz,angle);
}

void Poly_Fold_yz(inout dvec4 p, float order)
{
   float m = order/TWOPI;

   float angle = round(m*(-atan(float(p.y),float(p.z))))/m;

   p.xz=rotate(p.yz,angle);
}
But the sym version is different
;)


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: M Benesi on December 10, 2016, 11:13:26 PM
I did a far more complicated version with extra rotations in fragmentarium, if McLarekin can translate it... eventually.  

  Doy.. here is a Kaleidoscopic rotation demo- you can do multiple 3d polyfolds if you know multiple axes of symmetry and know the tricks to align them.  I'll write a tutorial if someone wants me to.

(http://i.giphy.com/l0HlRfGFgO11FoBDa.gif)

  If Luca checks it for redundancies, it basically does the polyfold stuff, but has extra cool Kaleidoscopic rotations thrown into the mix.


  If you want to avoid additional trig functions, set EXTRA_TRIG_FUNCTIONS=false, otherwise do it the extra trig function way.


  If you have an even number of polyfolds, set EvenFolds true for... less rotations.  

bool EvenFolds =  set true if Folds is even
float Rotate= kaleidscopic rotation variable...
float FoldAdjust=  adjustment so axis of symmetry (if you use an object with symmetry) is aligned correctly
float folds=  number of folds

  
Code:
        bool EXTRA_TRIG_FUNCTION=false;
        
float rxy;
float ratrack=pi2-pi2/folds;   //pi2 is 2*pi
float rotadjust=-pi/folds  + FoldAdjust;     // I called folds splits in my original code...
// I called them splits because I didn't know
float pintrack=pi/folds;      //what they were called.....
float pi2splits=pi2/folds;
float  i=0.0;    //why a float??  I was doing something with it...  

float omega=atan(z.y,z.x);
if (omega<0.0) {omega+=pi2;}    //so angle goes from 0 to 2pi instead of having negative part

float rotate=0;  

   //I only wanted to do the kaleidoscope rotations on specific iterations
  // doing multiple polyfolds... you can do it every iteration or whatever- for cool effects
  // only do it on specific iterations- I was making kaleidoscopes out of 2d polyfolding

if (RotateIter==n) {rotate=Rotate;}    //only do the rotation on a specific iteration


while (omega>pi2folds && i<floor(folds+1.0)) {
i+=1.0;

if (EvenFolds) {rotate*=-1;}    //if you have an even number of folds, you can do 1/2 as
                                                                 //many rotations- it's sort of cool

if (!EXTRA_TRIG_FUNCTION) {   //that is a NOT "!"  :D
rotadjust+=ratrack;
pintrack+=pi2folds;
omega-=pi2folds;
} else {     //with extra trig function, you don't need the above... just do the above instead
omega-=pi2folds;
}
}

if (EXTRA_TRIG_FUNCTION) {   // don't do this unless you absolutely love using transcendental functions
z=length(z)*vec2(cos(omega),sin(omega));
}

// if you don't have an even number of folds, you have to make an even number of rotations like the following:

if (omega>pi2folds*.5 && !EvenFolds) {rotate*=-1;}

// pintrack is used to shift the fold center outwords- images follow

vec2 z2=vec2(cos(pintrack),sin(pintrack));    

// splitrad is the distance from the center that the folds are shifted outwards

z.xy-=z2*splitrad;
rxy=length (z.xy);  

// rotadjust keeps every duplicate aligned correctly.  
omega=atan(z.y,z.x)+rotadjust+rotate+FoldAdjust;
z.xy=rxy * vec2(cos(omega),sin(omega));


return z;

  Did a 2d kaleidoscope using the above function:
(http://i.giphy.com/4DK5y5jFn3VQc.gif)

  And other stuff (polyfolds, and a modified boxtiling function):
(http://i.giphy.com/3o6ZsXK9Ks4HOs4mDm.gif)

 (http://i.giphy.com/3oz8xTc4b6SkWJWwUM.gif)


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 10, 2016, 11:39:11 PM
I feel I am about to be sidetracked yet again.  I will try in OpenCL first.

This formula should look real good with an "audio to parameter interface"

In theory I should be faster at coding and debugging by now, so give me a month. ;D


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: M Benesi on December 10, 2016, 11:54:15 PM
lol  :D


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: quaz0r on December 10, 2016, 11:56:48 PM
i think im startin to feel it  :alien:


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: DarkBeam on December 11, 2016, 12:07:33 AM
Just a month? More like six months :D


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: M Benesi on December 11, 2016, 01:29:15 AM
   this isn't hypnotic quaz0r... just a demo- it's cool to be able to rotate polyfolds...

  (http://i.giphy.com/qSl66rlo1qGm4.gif)

  Rotated it on the 2nd iteration (5 iterations total polyfolds- MengerIFS is already aligned for the code I wrote because of the symmetries of the Menger since I'm folding around the x axis).

 


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 11, 2016, 05:05:07 AM
Yes six months is more realistic for the actual formula development part

First is the paperwork, getting official permission from the relevant authorities .
Then I have to find financial backing in a world where only a chosen few know what a fractal is.
Pay the shadowy underground figures that actually secretly control the supply and demand in the fractal market.
I then need to get the consultants in for market research, mathematical input, and prep the media company in charge of presentation and dreaming up "wacky" ideas to publicize the official formula launch.


Then the difficult bit.

I get my brain out of storage, strip it down and rebuild it , fixing or replacing any damaged parts as best as  I can.  Provide necessary fuel, lubrication and coolant  :beer: :beer: :beer:.

A few test runs,  and some fine tuning, and we are ready to set a date to start on the development work.

It tires me out just thinking about it, there has got to be a better way of earning a living.

But then after the necessary 6 months, when we have the formula packaged and ready for the market, it all kind of feels worth the effort. And the formula release parties are not to be missed. :dink:


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: quaz0r on December 11, 2016, 06:48:53 AM
lubrication


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: DarkBeam on December 11, 2016, 11:16:29 PM
Oh my lol ;)
I hope for a speedup then  :beer:


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: M Benesi on December 12, 2016, 03:29:55 AM
Faster translation for Kaleidoscopic rotations for M3D too!!!

  Going to be able to do neat things...

(http://i.giphy.com/hmbtTEfS7Y4KY.gif)(http://i.giphy.com/2Ofnpfi0FhMGc.gif)

https://www.youtube.com/watch?v=meZtYlY3fUo&feature=youtu.be&spfreload=10


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 14, 2016, 04:04:33 AM
Well QT Creator is currently crashing if I try and finish coding 4D rotation , SOOOOO , let' s do something else



Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 14, 2016, 04:06:13 AM
First I needed to interest him by quoting maths.


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 14, 2016, 04:23:09 AM
So I gave Nifty a copy of Matt's code and told him to go away and study it. Nifty was not happy. :fiery:

        bool EXTRA_TRIG_FUNCTION=false;
       
   float rxy;
   float ratrack=pi2-pi2/folds;   //pi2 is 2*pi
   float rotadjust=-pi/folds  + FoldAdjust;     // I called folds splits in my original code...
// I called them splits because I didn't know
   float pintrack=pi/folds;      //what they were called.....
   float pi2splits=pi2/folds;
   float  i=0.0;    //why a float??  I was doing something with it... 
   
   float omega=atan(z.y,z.x);
   if (omega<0.0) {omega+=pi2;}    //so angle goes from 0 to 2pi instead of having negative part
   
   float rotate=0;   

   //I only wanted to do the kaleidoscope rotations on specific iterations
  // doing multiple polyfolds... you can do it every iteration or whatever- for cool effects
  // only do it on specific iterations- I was making kaleidoscopes out of 2d polyfolding

   if (RotateIter==n) {rotate=Rotate;}    //only do the rotation on a specific iteration

   
   while (omega>pi2folds && i<floor(folds+1.0)) {
         i+=1.0;
         
         if (EvenFolds) {rotate*=-1;}    //if you have an even number of folds, you can do 1/2 as
                                                                 //many rotations- it's sort of cool

            if (!EXTRA_TRIG_FUNCTION) {   //that is a NOT "!"  :D
               rotadjust+=ratrack;
               pintrack+=pi2folds;
               omega-=pi2folds;
            } else {     //with extra trig function, you don't need the above... just do the above instead
               omega-=pi2folds;
            }
         }

         if (EXTRA_TRIG_FUNCTION) {   // don't do this unless you absolutely love using transcendental functions
             z=length(z)*vec2(cos(omega),sin(omega));
         }

// if you don't have an even number of folds, you have to make an even number of rotations like the following:

      if (omega>pi2folds*.5 && !EvenFolds) {rotate*=-1;}

// pintrack is used to shift the fold center outwords- images follow

         vec2 z2=vec2(cos(pintrack),sin(pintrack));   

// splitrad is the distance from the center that the folds are shifted outwards
      
         z.xy-=z2*splitrad;
          rxy=length (z.xy);   
         
// rotadjust keeps every duplicate aligned correctly.        
          omega=atan(z.y,z.x)+rotadjust+rotate+FoldAdjust;
         z.xy=rxy * vec2(cos(omega),sin(omega));


   return z;


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 14, 2016, 05:11:59 AM
But hten he was "hooked" and came back with his version of the Initial Conditions. He had recoded it to remove some divisions. Then he showed me his first render, unfortunately  it did not look like it should.


Code:
uniform bool EvenFolds; checkbox[true]
uniform bool EXTRA_TRIG_FUNCTION; checkbox[false]

uniform float folds; slider[1,4,50]
uniform float splitrad; slider[0,0,50]
uniform float FoldAdjust; slider[0,0,50]
uniform int RotateIter; slider[0,1,50]
float Rotate;
float rotate = 0.0;
int n = 0;
int i = 0;
float pi2 = 2 * M_PI_F;
float pi = M_PI_F;
float rxy;
float omega;
float pintrack = pi / folds;
float pi2folds = pi2 / folds;
float ratrack = pi2 - pi2folds;
float rotadjust = -pintrack + FoldAdjust;       
omega = atan(z.y,z.x);
if (omega < 0.0) {omega += pi2;}    //so angle goes from 0 to 2pi instead of having negative part
//if (RotateIter == n) {rotate = Rotate;}    //only do the rotation on a specific iteration


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: M Benesi on December 15, 2016, 01:51:09 AM
 ;D  :D

  K... I explain momentarily. 


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 15, 2016, 02:18:43 AM
As you can see , I have decided not to get my brain out of storage, and I am using young Nifty's clever young brain instead.

Later he came back with some more images. Sadly his code was still not working and I had to send him back to his room. Using the old " no working code means no dinner" threat.


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 15, 2016, 07:14:31 AM
He then came back with this poor excuse for a polyfold menger.  Let me have a look at your code young man! :police:


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: M Benesi on December 15, 2016, 07:15:17 AM
  So.. have a kaleidoscopic rotation polyfold thingy for M3D now.  

https://drive.google.com/open?id=0B0EcJQ49B_yOSUJzRXBDc3JSY0k

(http://i.giphy.com/3o7TKpYLdQIJn0PN1S.gif)

(http://i.giphy.com/3o6ZsSZl76IJ8iJGqk.gif)

  Still need to split off the accordion functionnnnnn so it's standalone (in that gif, using old code), which is basically a souped up boxtiling function.



   @mcclarekin-  Getting up early, might or might not get in code tomorrow (big thing after work) so you might have to decipher the following if you want to play around before the rainy day on Friday (might have all afternoon on Friday (due to rain) to code and stuff!!) so....

https://drive.google.com/open?id=0B0EcJQ49B_yOS1Iyd2gzbl8tek0



Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 15, 2016, 07:22:11 AM
Then I remembered I had chosen not to use my brain this week, so I told Nifty you will have to seek guidance from Uncle Matt.

I noticeed Nifty was confused about rotate , "n" and how the "while"  loop works.


Code:
// Iter loop 

//14-12-16

   //I only wanted to do the kaleidoscope rotations on specific iterations
  
// doing multiple polyfolds... you can do it every iteration or whatever- for cool effects
  
// only do it on specific iterations- I was making kaleidoscopes out of 2d polyfolding

//if (RotateIter == n) {rotate = Rotate;}    //only do the rotation on a specific iteration

if (omega > pi2folds && i < floor(folds + 1.0))
{

//i += 1;

if (EvenFolds == 0) {rotate *= -1;}
   {
//if you have an even number of folds, you can do half
//many rotations it's sort of cool

if (EXTRA_TRIG_FUNCTION != 0)//that is a NOT "!"  :D
{  
rotadjust += ratrack;
pintrack += pi2folds;
omega -= pi2folds;
}
else
{     //with extra trig function, you don't need the above... just do the above instead. what????
omega -= pi2folds;
}
}


if (EXTRA_TRIG_FUNCTION == 0)
{   // don't do this unless you absolutely love using transcendental functions

//z = length(z) * (float2){(cos(omega), sin(omega));
rxy = length(z.xy);
z.x = rxy * cos(omega);
z.y = rxy * sin(omega);
}



// if you don't have an even number of folds, you have to make an even number of rotations like the following:

if (omega > pi2folds * 0.5 && EvenFolds != 0) {rotate *= -1;}


// pintrack is used to shift the fold center outwords- images follow
// splitrad is the distance from the center that the folds are shifted outwards
//vec2 z2=vec2(cos(pintrack),sin(pintrack));  
//z.xy-=z2*splitrad;

z.x -= cos(pintrack) * splitrad;
z.y -= sin(pintrack) * splitrad;
rxy = length(z.xy);
// rotadjust keeps every duplicate aligned correctly.
omega = atan(z.y/z.x) + rotadjust + rotate + FoldAdjust;
//z.xy=rxy * vec2(cos(omega),sin(omega));
z.x = rxy * cos(omega);
z.y = rxy * sin(omega);

}

z = fabs( z );

if (z.x < z.y ) z.xy = z.yx;

if (z.x < z.z ) z.xz = z.zx;

if (z.y < z.z ) z.yz = z.zy;



//Rotation (Mandelbox Tab, - main rotation)
z = Matrix33MulFloat3(consts->fractal.mandelbox.mainRot, z);


z *= ScaleM;
DE *= ScaleM; // * Tweak


z.x -= OffsetM.x;

z.y -= OffsetM.y;

//
if (Enable.z == 1) // standard z.z condition for Menger Sponge

//{

if (z.z > 1.0) z.z -= OffsetM.z;

//}
//else
//{
// z.z -= OffsetM.z;
//}


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 15, 2016, 08:32:05 AM
I thought I might as well zoom into young Nifty's image to see what made up the top stuff.


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: DarkBeam on December 15, 2016, 09:35:10 AM
Whut? Is it still continuous? Or you have sliced it like sushi :hurt:


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 15, 2016, 09:54:56 AM
Discontinuous  :sad1:


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: DarkBeam on December 15, 2016, 10:05:17 AM
The best try is just using Polyfold_sym as it is.
On even fold count discontinue on one half plane (not very visible). Else perfectly continue.
I remember the trick was to check the parity of the integer obtained from atan(). Change sign of y accordingly.
And probably in case of even folds.... do abs(y) on the sector n°zero. Not tested ;) might be wrong


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on December 15, 2016, 10:14:52 AM
I made it continuous   :)

I will look to M3D soon, but am having fun mucking about with something I havent quite figured out yet.

BTW I am currently distracted by your Smooth Menger O0


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: DarkBeam on December 15, 2016, 10:17:07 AM
Code:
void Poly_Fold_sym(inout dvec4 p, int order)
{
   float m = (float)order/TWOPI;
   bool cy = false; // lol... not glsl anymore

   int sector = (int)(m*(-atan(float(p.x),float(p.y))));
   if (sector&1) cy= true; // parity
   float angle = (float)sector/m;
   p.xy=rotate(p.xy,angle);
   if (cy) p.y=-p.y;
   // if ((order&1) && (sector ==0)) p.y = fabs(p.y); // more continuous?
}

To be tried ;)


Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: AtomicNixon on August 09, 2017, 06:35:44 PM
Quick question.... I'm looking to port some formulas from Mandelbulber into Fragmentarium and I ran across this...
z = Matrix33MulFloat3(consts->fractal.mandelbox.mainRot, z);

So I looked in the .h libraries from the latest build and um.....  Looking at that I know that I must have looked at the Fragmentarium equivalent and not had a clue.  These algos are so damn frustrating!  They're so short and compact, it doesn't look like they're able to do anything at all, and yet... Oh, first week out?  How did you guess!  Oh I'll wrap my head around it, no worries, but in the meanwhile I could use a pointer or two and maybe a point towards some required reading?

My first real target is to get that _polyfold_sym function slapped on top of a Kaliboxmod set so I can render these beasties at GPU rendering speed. 
https://www.youtube.com/watch?v=d2dmPDA2Xbo



Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: mclarekin on August 10, 2017, 03:32:01 AM
Hi AtomicNixon

I had forgotten I was supposed to be working on the polyfolds stuff  :embarrass:  Darkbeam optimistically suggested it would take me 6 months, lol.


a)   the z = matrix etc  http://www.fractalforums.com/index.php?topic=24826.msg98735#msg98735

try this

vect3 tp =
 
Code:
	if (angleXY != 0)
{
tp = z;
z.x = tp.x * cos(angleXY) + tp.y * sin(angleXY);
z.y = tp.x * -sin(angleXY) + tp.y * cos(angleXY);
}
if (angleYZ != 0)
{
tp = z;
z.y = tp.y * cos(angleYZ) + tp.z * sin(angleYZ);
z.z = tp.y * -sin(angleYZ) + tp.z * cos(angleYZ);
}
if (angleXZ != 0)
{
tp = z;
z.x = tp.x * cos(angleXZ) + tp.z * sin(angleXZ);
z.z = tp.x * -sin(angleXZ) + tp.z * cos(angleXZ);
}

b) required reading,  Almost everything I have learnt has come  the advice given ,and code posted, at this forums. But for specific information it is often easier to ask then try and find it amongst this large archive of knowledge.


c) Mandelbulber V2.12 alpha is GPU powered,  most if not all of Mandelbulber V2.11 formulas work .  https://github.com/buddhi1980/mandelbulber2/releases

Any  testing of this alpha version by others is appreciated



Title: Re: _polyfold_sym and polyfoldsymIFS in mandelbulber 2
Post by: AtomicNixon on August 11, 2017, 08:30:54 PM
A) Thanks, part of the essentials I'll have to get down.  Very pleased with how I've been getting along though and it gets easier and easier with each Aha!  Like finding you can toss ISO formulas at it and click, answer to how all of it works.  Nothing like the clarity you achieve on your own.  "Poke it with a stick!"  Tossed this shape in for it to use last night and this came out. 

   return ((p.x*p.x)-(p.y*p.y)-(p.z*p.z));

(http://i.imgur.com/B4OcA1h.jpg)

C) Alpha 5, that's the one I've got.  I'd like to translate some of the custom formulas in Ver 1.21 over.  Decided that if I wanted total freedom and mastery though, Frag was the way to go.  Learning OpenGL and such has been on my must-do list for a very long time now and I'm just happy to be finally at it.  Coding frenzy, dragged away once in awhile to have food shoved in, naked half the day because I was only going to get up to check that render and then I thought of something so now it's 3:00 pm and....   :D  Joy!