the beauty of fractal math
Sierpinski KIFS, with a built-in 4D rotation.
KIFS stands for kaleidoscopic iterated function system
based on the Sierpinski Triangle
float Sierpinski4
{
float r;
int n = 0;
while (n < Iterations) {
// hyper-tetraedral folding
if(z.x+z.y<0.0) z.xy = -z.yx;
if(z.x+z.z<0.0) z.xz = -z.zx;
if(z.y+z.z<0.0) z.zy = -z.yz;
if(z.x+z.w<0.0) z.xw = -z.wx;
if(z.y+z.w<0.0) z.yw = -z.wy;
if(z.z+z.w<0.0) z.zw = -z.wz;
Rotate4D (z,Angles4D); //
z = z*Scale - Offset4*(Scale-1.0);
n++
}
return (length(z) ) * pow(Scale, -float(n));
}
formula originally written by Syntopia and refined for mandelbulb renderer by Luca_GN2011
big shoutout...