### Folding Menger the "DB" way

• 7 Replies
• 308 Views

0 Members and 1 Guest are viewing this topic.

#### 3DickUlus

• • 3f
•      • Posts: 1487 #### Folding Menger the "DB" way

« on: December 08, 2018, 08:23:48 AM »
These are both based on the Menger_Sphere.frag from Examples/knighty's Collection
I hacked the DeltaDE code from buddhi into it and the details are amazing!

Just the menger... Folded menger with applied domain mashup... DarkBeam's folding code from that old frag...

add some variables for control and the bool switch for serial vs parallel...
Code: [Select]
uniform vec3 fo; slider[(0.,0,0),(0.5,0.5,0.5),(2.,2.,2.)]uniform vec3 g; slider[(0.,0,0),(0.1,0.1,0.1),(2.,2.,2.)]uniform bool Serial; checkbox[false]add the fold subroutines...
Code: [Select]
//DarkBeam's "fold"... reinterpreted... it's more than a fold, much more! Just awesome!float DBFold(vec3 p, float fo, float g){ if(p.z>p.y) p.yz=p.zy;//Diagonal fold //Tis is slightly different from the original fold in order to make it continuous in this context float vx=p.x-2.*fo; float vy=p.y-4.*fo;  float v=max(abs(vx+fo)-fo,vy); float v1=max(vx-g,p.y); v=min(v,v1); return min(v,p.x);}//the coordinates are pushed/pulled in parallelvec3 DBFoldParallel(vec3 p, vec3 fo, vec3 g){ vec3 p1=p; p.x=DBFold(p1,fo.x,g.x); p.y=DBFold(p1.yzx,fo.y,g.y); p.z=DBFold(p1.zxy,fo.z,g.z); return p;}//serial versionvec3 DBFoldSerial(vec3 p, vec3 fo, vec3 g){ p.x=DBFold(p,fo.x,g.x); p.y=DBFold(p.yzx,fo.y,g.y); p.z=DBFold(p.zxy,fo.z,g.z); return p;}
...then, before the iteration loop...
Code: [Select]
 //Apply pull transformation vec3 signs=sign(p);//Save the original signs p=abs(p); if(Serial) p=DBFoldSerial(p,fo,g); else p=DBFoldParallel(p,fo,g); p*=signs;//restore signs: this way the mandelbrot set won't extend in negative directions... and if you put the above code inside the iteration loop... this should work with any fractal formula?

« Last Edit: December 08, 2018, 10:36:54 AM by 3DickUlus, Reason: links n thumbs »
Fragmentarium is not a toy, it is a very versatile tool that can be used to make toys https://en.wikibooks.org/wiki/Fractals/fragmentarium

#### 3DickUlus

• • 3f
•      • Posts: 1487 #### Re: Folding Menger the "DB" way

« Reply #1 on: December 10, 2018, 02:17:05 AM »

#### mclarekin #### Re: Folding Menger the "DB" way

« Reply #2 on: December 10, 2018, 02:18:48 AM »

#### 3DickUlus

• • 3f
•      • Posts: 1487 #### Re: Folding Menger the "DB" way

« Reply #3 on: December 10, 2018, 02:59:13 AM » that was part of my tests re:board blocking, so it's quite new, this is the first time I've used the image threads board, it could be handy for this sort of thing,
we'll see how things unfold yes, I actually said that #### Sabine62

• • Moderator
•      • Posts: 663 #### Re: Folding Menger the "DB" way

« Reply #4 on: December 10, 2018, 01:04:19 PM »
I thought I had replied here already 3Dickulus, again great stuff to have, thanks for posting here!
Reminds me that I have some transforms still lying around that can be used as pre-post-and normal transforms that I mean to post here but keep forgetting...  To thine own self be true

#### 3DickUlus

• • 3f
•      • Posts: 1487 #### Re: Folding Menger the "DB" way

« Reply #5 on: March 08, 2019, 05:22:42 AM »
here are some more folding functions...
Code: [Select]
void sphereFold(inout vec3 z, inout float dz) { float r2 = dot(z,z); if (r2< minRadius2) { float temp = (fixedRadius2/minRadius2); z*= temp; dz*=temp; } else if (r2<fixedRadius2) { float temp =(fixedRadius2/r2); z*=temp; dz*=temp; }}
Code: [Select]
void boxFold(inout vec3 z, inout float dz) { z = clamp(z, -foldingLimit, foldingLimit) * 2.0 - z;}
Code: [Select]
void boxFold3(inout vec3 z, inout float dz) { if (z.x>foldingLimit) { z.x = foldingValue-z.x; }  else if (z.x<-foldingLimit) z.x = -foldingValue-z.x; if (z.y>foldingLimit)  { z.y = foldingValue-z.y;  } else if (z.y<-foldingLimit) z.y = -foldingValue-z.y; if (z.z>foldingLimit)  { z.z = foldingValue-z.z ; } else if (z.z<-foldingLimit) z.z = -foldingValue-z.z;}
Code: [Select]
void mengerFold(inout vec3 z, inout float dz) { z = abs(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;} z = Scale*z-Offset*(Scale-1.0); if( z.z<-0.5*Offset.z*(Scale-1.0))  z.z+=Offset.z*(Scale-1.0); dz*=Scale;}
Code: [Select]
void octo(inout vec3 z, inout float dz) { if (z.x+z.y<0.0) z.xy = -z.yx; if (z.x+z.z<0.0) z.xz = -z.zx; if (z.x-z.y<0.0) z.xy = z.yx; if (z.x-z.z<0.0) z.xz = z.zx; z = z*Scale2 - Offset2*(Scale2-1.0); dz*= Scale2;}
the attached frag is only one way of mixing these up definitely not the only way edit: easingcurves are used for fade-in and fade-out needs 240 seconds (also works just fine without the easing curves)

#### Sabine62

• • Moderator
•      • Posts: 663 #### Re: Folding Menger the "DB" way

« Reply #6 on: March 08, 2019, 09:49:42 AM » Great folding options and I very much enjoyed the animation, thank you, Dick!

#### 3DickUlus

• • 3f
•      • Posts: 1487 #### Re: Folding Menger the "DB" way

« Reply #7 on: March 09, 2019, 06:27:12 AM »
tha script ArtOfFolding is experimental unfinished alpha, just for mucking about with combining routines ### Similar Topics ###### Folding Menger the "DB" way: A study of structures

Started by 3DickUlus on Image Threads

20 Replies
657 Views December 13, 2018, 06:15:32 AM
by 3DickUlus ###### Dark Matter Menger--"Anthony"--3D Fractals & Music

Started by Paigan0 on Fractal movie gallery

3 Replies
162 Views January 01, 2019, 01:13:59 PM
by Sabine62 ###### Menger fractal "Through time and space"

Started by Nintendokater on Fractal Image Gallery

0 Replies
254 Views April 12, 2019, 06:07:31 PM
by Nintendokater Started by Kalter Rauch on Fractal Image Gallery

14 Replies
488 Views November 16, 2018, 08:52:10 PM
by Kalter Rauch ###### Fractal zooms: "redshiftriders", "libra" and "down down down"

Started by RedshiftRider on Fractal movie gallery

0 Replies
198 Views December 10, 2018, 09:30:59 PM
by RedshiftRider