It is just an idea. Here is the original code.
Menger3(x,y,z){ // (c) knighty
r=x*x+y*y+z*z;
for(i=0;i<MI && r<bailout;i++){
rotate1(x,y,z);
x=abs(x);y=abs(y);z=abs(z); // abs
if(x-y<0){x1=y;y=x;x=x1;} // swap 1
if(x-z<0){x1=z;z=x;x=x1;} // swap 2
if(y-z<0){y1=z;z=y;y=y1;} // swap 3
z-=0.5*CZ*(scale-1)/scale;
z=-abs(-z); // abs
z+=0.5*CZ*(scale-1)/scale;
rotate2(x,y,z);
x=scale*x-CX*(scale-1);
y=scale*y-CY*(scale-1);
z=scale*z;
r=x*x+y*y+z*z;
}
return sqrt(x*x+y*y+z*z)*scale^(-i);
}
To make a smoothed out version we must replace all swaps and abs() with smooth functions.
The trouble is smooth the swaps
Defining this formula:
function s0(a) {return (a<0)?a:0;}
T=s0(x-y);
X=x-t;
Y=y+t;
It also does the trick.
Now defining...
function s1(a,b) {return (0.5*(a-sqrt(a*a+b)));} // b must be positive
T=s1(x-y,smoothfac);
X=x-t;
Y=y+t;
The bigger is the factor the smoother is the swap. Zero leads to the same result as the conditional swap. (Or it really should!)
As for smoothing abs you use sqrt(a*a+b) with the same meaning and precaution.
No renders for now
anyone can try this?
Edit. Never mind. Fixed a stupid error