DarkBeam
Global Moderator
Fractal Senior
Posts: 2512
Fragments of the fractal -like the tip of it
|
|
« on: June 11, 2016, 09:45:02 AM » |
|
Looks very amazing! http://paulbourke.net/fractals/crossmenger/Can you do this fractal for Fragmentarium too? Using a KIFS routine ofc! Must be interesting as it mixes geometries
|
|
« Last Edit: June 11, 2016, 01:32:59 PM by DarkBeam »
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
|
knighty
Fractal Iambus
Posts: 819
|
|
« Reply #2 on: June 22, 2016, 01:45:12 AM » |
|
Hi, Not eazy #info CrossMenger #include "DE-Raytracer.frag" #group CrossMenger
// Number of fractal iterations. uniform int Iterations; slider[0,3,100] uniform float Gap; slider[0.,1.,1.] uniform bool KIFS; checkbox[false]
float baseshape(vec3 p, float s){ p.yz=abs(p.yz); float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) ); p.xy -= t*vec2(-sqrt(3.),1.)*0.5; p.y=abs(p.y); if(p.y>p.z) p.yz=p.zy; p-=s*vec3(0.5*sqrt(3.),1.5,1.5); if(p.z>p.x){p.xz=p.zx;} if(p.x<0.) return p.x; p.yz=max(vec2(0.),p.yz); return length(p); }
float CrossMengerTrick(vec3 p){//use Msltoe's method. Gives correct result but the DE is discontinuous float dd=1.; for(int i=0; i<Iterations;i++){ p.yz=abs(p.yz); float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) ); p.xy -= t*vec2(-sqrt(3.),1.)*0.5; p.y=abs(p.y);
p.x-=sqrt(3.)*0.5; //Choose nearest corner/edge --> to get translation symmetry float dy=0., dz=0.; if(p.y>0.5 && p.z>0.5){dy=1.5; dz=1.5;} else if((p.y-1.5)*(p.y-1.5)+p.z*p.z<p.y*p.y+(p.z-1.5)*(p.z-1.5)) dy=1.5; else dz=1.5; p.y-=dy; p.z-=dz; p*=3.; dd*=1./3.; p.y+=dy; p.z+=dz; p.x+=sqrt(3.)*0.5; } return dd*baseshape(p,Gap); }
float CrossMengerKIFS(vec3 p){//Pure KIFS... almost correct float dd=1.; for(int i=0; i<Iterations;i++){ p.yz=abs(p.yz); float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) ); p.xy -= t*vec2(-sqrt(3.),1.)*0.5; p.y=abs(p.y); if(p.y>p.z) p.yz=p.zy; p.y=abs(p.y-0.5)+0.5; p-=vec3(0.5*sqrt(3.),1.5,1.5); p*=3.; dd*=1./3.; p+=vec3(0.5*sqrt(3.),1.5,1.5); } return dd*baseshape(p,Gap); }
float DE(vec3 pos) { if(KIFS) return CrossMengerKIFS(pos); return CrossMengerTrick(pos); }
|
|
|
Logged
|
|
|
|
DarkBeam
Global Moderator
Fractal Senior
Posts: 2512
Fragments of the fractal -like the tip of it
|
|
« Reply #3 on: June 22, 2016, 12:43:03 PM » |
|
hehe you never fail to amaze us!
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
Crist-JRoger
|
|
« Reply #4 on: June 22, 2016, 07:18:24 PM » |
|
Thank you very much! Rotated looks good #define providesInit #include "MathUtils.frag"
uniform vec3 Rot1; slider[(-180,-180,-180),(0,0,0),(180,180,180)] uniform vec3 Rot2; slider[(-180,-180,-180),(0,0,0),(180,180,180)]
mat3 fracRotation1; mat3 fracRotation2;
void init() { fracRotation1 =rotationMatrixXYZ(vec3(Rot1.x,0.0,0.0))*rotationMatrixXYZ(vec3(0.0,Rot1.y,0.0))*rotationMatrixXYZ(vec3(0.0,0.0,Rot1.z)); fracRotation2 =rotationMatrixXYZ(vec3(Rot2.x,0.0,0.0))*rotationMatrixXYZ(vec3(0.0,Rot2.y,0.0))*rotationMatrixXYZ(vec3(0.0,0.0,Rot2.z)); }
float CrossMengerTrick(vec3 p){//use Msltoe's method. Gives correct result but the DE is discontinuous float dd=1.; for(int i=0; i<Iterations;i++){ p.yz=abs(p.yz); float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) ); p.xy -= t*vec2(-sqrt(3.),1.)*0.5; p.y=abs(p.y);
p.x-=sqrt(3.)*0.5; //Choose nearest corner/edge --> to get translation symmetry float dy=0., dz=0.; if(p.y>0.5 && p.z>0.5){dy=1.5; dz=1.5;} else if((p.y-1.5)*(p.y-1.5)+p.z*p.z<p.y*p.y+(p.z-1.5)*(p.z-1.5)) dy=1.5; else dz=1.5; p.y-=dy; p.z-=dz; p=fracRotation1*p;
p*=3.; dd*=1./3.; p.y+=dy; p.z+=dz; p.x+=sqrt(3.)*0.5; p=fracRotation2*p;
} return dd*baseshape(p,Gap); }
|
|
|
Logged
|
|
|
|
DarkBeam
Global Moderator
Fractal Senior
Posts: 2512
Fragments of the fractal -like the tip of it
|
|
« Reply #5 on: June 22, 2016, 10:09:46 PM » |
|
Heyyy can you post a render of the kifs version? plzzz
|
|
|
Logged
|
No sweat, guardian of wisdom!
|
|
|
mclarekin
|
|
« Reply #6 on: June 23, 2016, 12:12:00 AM » |
|
It is a cool maths, and I am still far from understanding it and getting it coded.
It will be interesting to see the hybrids that can be made with it.
One question for now, what is "s" that is being brought into the baseshape?
|
|
|
Logged
|
|
|
|
Crist-JRoger
|
|
« Reply #7 on: June 23, 2016, 12:47:01 AM » |
|
Heyyy can you post a render of the kifs version? plzzz
KIFS rotated, fullscreen super resolution mode, 3000 subframes, palette by M Benesi float CrossMengerKIFS(vec3 p){//Pure KIFS... almost correct float dd=1.; for(int i=0; i<Iterations;i++){ p=fracRotation1*p; p.yz=abs(p.yz); float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) ); p.xy -= t*vec2(-sqrt(3.),1.)*0.5; p.y=abs(p.y); if(p.y>p.z) p.yz=p.zy; p.y=abs(p.y-0.5)+0.5; p-=vec3(0.5*sqrt(3.),1.5,1.5); p*=3.; dd*=1./3.; p+=vec3(0.5*sqrt(3.),1.5,1.5); p=fracRotation2*p; orbitTrap = min(orbitTrap, abs(vec4(p.xyz,dot(p,p)))); } return dd*baseshape(p,Gap); }
|
|
|
Logged
|
|
|
|
M Benesi
|
|
« Reply #8 on: June 23, 2016, 06:27:29 AM » |
|
Sweet.
|
|
|
Logged
|
|
|
|
Crist-JRoger
|
|
« Reply #9 on: June 23, 2016, 12:02:16 PM » |
|
It will be interesting to see the hybrids that can be made with it.
Pseudo-Kleinian hybrid looks awesome intel gpu quick render
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #10 on: June 23, 2016, 12:41:41 PM » |
|
Wow! that is beautiful.
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #11 on: June 23, 2016, 02:11:30 PM » |
|
Thanks Knighty, I have only coded the basic shape so far, and now I am sidetracked into testing it out on various formulas.
|
|
|
Logged
|
|
|
|
Crist-JRoger
|
|
« Reply #12 on: June 23, 2016, 03:56:54 PM » |
|
mclarekin, nice shapes ) so, just little fun:
|
|
|
Logged
|
|
|
|
knighty
Fractal Iambus
Posts: 819
|
|
« Reply #13 on: June 24, 2016, 02:14:34 AM » |
|
Wow! those are awesome and really unexpected results. FYI, The base sape is not really necessary if you use a lot of iterations. It is there only for low iteration. One can replace it with a sphere as usual. The s parameter is there only to give the gaps and get a picture that looks like those of the OP. (just experiement with the Gap slider to see what I mean )
|
|
|
Logged
|
|
|
|
mclarekin
|
|
« Reply #14 on: June 24, 2016, 04:33:41 AM » |
|
Wow! Yes that's what I have been thinking , from the time I first saw the post. FYI, The baseshape is not really necessary if you use a lot of iterations. It is there only for low iteration. One can replace it with a sphere as usual. So it is a pre-transform necessary for low iteration formulas. I did a bit of this in Mandelbulber V1.21OpenCL but we have yet to set up an "Initial Conditions" feature to easily implement pre_transforms in MandelbulberV2 Thanks for info. just experiment with the Gap slider I still havent coded it yet, LOL, (I am slow and easily distracted),as the baseshape is too interesting. I have being mixing it successfully with various Abox/Mbox & menger type fractals with generally good analytic DE results. But here a two questions. 1) Has the baseshape got a name (prism??) because I will add it as a Transform as well as using it in a Formula UI?? 2) This bit confuses me if(p.x<0.) return p.x; in .frag language does it mean "if p.x is neg return as pos" same as abs?? (I am not a real programmer, just an apprentice fractal coder) I know the answer I just forgot LOL, Cheers BTW This is a draft c++ version of the baseshape with some multiplications removed and constants added. void CrossMengerIteration(CVector3 &z, CVector3 &c, int i, const cFractal *fractal, sExtendedAux &aux) { double s = fractal->transformCommon.scale1; // find out where s comes from double gap = fractal->transformCommon.scale;// double t; double temp; double sqr3 = SQRT_3; double sqr305 = 0.86602540378443864676372317075294;
if(i >= fractal->transformCommon.startIterations && i < fractal->transformCommon.stopIterations) // temporary controls { z.y = fabs(z.y); z.z = fabs(z.z); double dot = z.x * -sqr305 + z.y * 0.5; t = max(0.0, dot); // if dot neg , t= 0 z.x -= t * -sqr3; // z.x moves pos dir z.y = fabs(z.y - t); if(z.y > z.z) // z.z pos { temp =z.y; z.y = z.z; z.z = temp; // z.z is the biggest pos } z -= s * CVector3( sqr305, 1.5, 1.5); // "s" scale of vec being subtracted, s from where?? // z was pos, now some points neg (ie neg shift) if(z.z > z.x) { temp =z.z; z.z = z.x; z.x = temp; // z.x is the biggest } if(z.x < 0.0 ) z.x = -z.x; // channge to positive ??? z.y = max(0.0, z.y); z.z = max(0.0, z.z);
z = fractal->transformCommon.rotationMatrix.RotateVector(z);
|
|
« Last Edit: June 24, 2016, 06:46:28 AM by mclarekin, Reason: Remembered what I forgot.Old tired brain. »
|
Logged
|
|
|
|
|