Welcome to Fractal Forums

Fractal Software => Fragmentarium => Topic started by: DarkBeam on June 11, 2016, 09:45:02 AM




Title: Cross Menger!? Can anyone do this?
Post by: DarkBeam 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


Title: Re: Cross Menger!? Can anyone do this?
Post by: Max Sinister on June 13, 2016, 07:24:29 PM
It's not exactly the same, but I programmed the half Menger sponge as a 3D printable file, here:
https://www.shapeways.com/shops/fractals-procgen


Title: Re: Cross Menger!? Can anyone do this?
Post by: knighty on June 22, 2016, 01:45:12 AM
Hi,
Not eazy :/

Code:
#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);
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on June 22, 2016, 12:43:03 PM
hehe you never fail to amaze us! :cantor_dance: :cantor_dance:


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on June 22, 2016, 07:18:24 PM
Thank you very much!  :) Rotated looks good  :D


(http://img03.deviantart.net/e7c3/i/2016/174/4/5/crossmenger_rot_by_crist_jroger-da7c8s8.jpg) (http://orig15.deviantart.net/d7a3/f/2016/174/4/1/crossmenger_rot_by_crist_jroger-da7c8s8.jpg)

Code:
#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);
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on June 22, 2016, 10:09:46 PM
Heyyy can you post a render of the kifs version? plzzz


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin 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?


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on June 23, 2016, 12:47:01 AM
Heyyy can you post a render of the kifs version? plzzz
:D
KIFS rotated, fullscreen super resolution mode, 3000 subframes, palette by M Benesi  :)

(http://pre01.deviantart.net/a574/th/pre/f/2016/174/3/a/cross_menger_kifs_by_crist_jroger-da7dk0b.jpg) (http://orig06.deviantart.net/0be7/f/2016/174/3/a/cross_menger_kifs_by_crist_jroger-da7dk0b.jpg)


(http://pre06.deviantart.net/6903/th/pre/f/2016/174/2/1/cross_menger_kifs_2_by_crist_jroger-da7dlow.jpg) (http://orig11.deviantart.net/44a0/f/2016/174/2/1/cross_menger_kifs_2_by_crist_jroger-da7dlow.jpg)

Code:
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);
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: M Benesi on June 23, 2016, 06:27:29 AM
Sweet.  :D


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger 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  :dink:
intel gpu quick render
(http://orig12.deviantart.net/bddb/f/2016/175/a/6/pkleinian_cm_test_by_crist_jroger-da7fn9j.jpg)


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on June 23, 2016, 12:41:41 PM
Wow! that is beautiful.    O0


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin 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. O0


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on June 23, 2016, 03:56:54 PM
mclarekin, nice shapes )

so, just little fun:
(http://orig15.deviantart.net/dc01/f/2016/175/8/9/pkleinian_cm_test2_by_crist_jroger-da7g54e.jpg)


Title: Re: Cross Menger!? Can anyone do this?
Post by: knighty 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 :D )


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on June 24, 2016, 04:33:41 AM
Quote
Wow!
Yes that's what I have been thinking , from the time I first saw the post.

Quote
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.

Quote
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)
 :embarrass: I know the answer I just forgot LOL,  :embarrass:

Cheers

BTW This is a draft c++ version of the baseshape with some multiplications removed and constants added.

Code:
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);


Title: Re: Cross Menger!? Can anyone do this?
Post by: knighty on June 25, 2016, 02:24:55 AM
Well... no. The base shape (which is indeed a prism with an equilateral triangular base) have nothing to do with pre-transform. It is just a convex hull of the fractal. IMHO, you don't need to implement the base shape as an iteration.
You are right, there is a lot of room for optimization. for example:
Code:
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.)*0.5;
can be replaced by:
Code:
float t = max(0., dot(p.xy, vec2(-sqrt(3.)*0.5 , 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.);

It seems you forgot a 2 factor in :
Code:
double dot = z.x * -sqr305 + z.y * 0.5;
it should be:
Code:
double dot = z.x * -sqr3 + z.y;


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on June 25, 2016, 06:39:00 AM
Probably in Mandelbulber V2.09 we will have it set up to make it easier to do maths outside the iteration loop.  But currently I have to use  a single iteration at the beginning inside the  loop. (.ie . if( i < 1). (but is currently set up for testing, so I temporary  itr start and itr stop parameters).

"It is just a convex hull of the fractal",  that is a good definition.

This is my optimisation path, and I still seem to end  up with the same line          double dot = z.x * -sqr305 + z.y * 0.5;h.mmm???
 I can not see a mistake (but that is a common thing for me, ie. 10minutes to code it "perfectly" , then several hours to find and fix the imperfections ;D)

original
float t = 2. * max(0., dot(p.xy, vec2(-sqrt(3.) * 0.5, 0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.)*0.5;

optimised
float t = max(0.,  dot(p.xy,    vec2(-sqrt(3.) * 0.5,     0.5)) );
p.xy -= t*vec2(-sqrt(3.),1.); // same as Knighty's example

where dot part  = ( p.x  * -sqrt(3.) * 0.5) + (p.y * 0.5)

 code to c++
dot1 = (z.x * -sqr305)  + (z.y * 0.5); // sqr305 = constant sqr3 * 0.5
t = max( 0.0 , dot1);

z.x -= t * -sqr3;
z.y -= t;    //   or  z.y = z.y - t
//.............................................
//Next line is
//z.y = fabs(z.y) //
// optimise with previous line
//    becomes z.y = fabs(z.y - t).
//.........................................................

c++
dot1 = (z.x * -sqr305)  + (z.y * 0.5); // sqr305 = sqr3 * 0.5
t = max( 0.0 , dot1);
z.x -= t * -sqr3;
z.y = fabs(z.y – t); and these lines are also used  in CrossMengerTrick and  CrossMengerKIFS which I am finally starting to look at


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on June 26, 2016, 02:56:03 AM
I have a better understanding of  how this .frag  works now,  ;D, (I was lacking some real basic programming knowledge.) So I feel embarrassed for a minute, then move on, LOL. 

This is the first time I have seen and understood how  a base shape can be used  O0, A whole new area of formulas that I have yet to explore. Will there ever be an end to this infinity of possibilities??



Title: Re: Cross Menger!? Can anyone do this?
Post by: knighty on June 26, 2016, 02:58:15 AM
No!  ;D
(the N in No stans for No) ;)

BTW, you can get the KIFS version without coding in mandelbulber.
Code:
# Mandelbulber settings file
# version 2.07
# only modified parameters
[main_parameters]
aux_light_enabled_1 true;
aux_light_intensity_1 1,41254;
aux_light_position_1 5 -3 3;
camera 3,365672583055189 -3,804478575040412 2,714269048418577;
camera_distance_to_target 2,604907989501952;
camera_rotation 25,86963147804066 -31,02749091811327 -1,416340756589222e-13;
camera_top -0,2249033775581471 0,4637956897721983 0,8569200831534224;
formula_1 10;
keyframe_last_to_render 0;
main_light_intensity 1,07;
target 2,391708951148566 -1,795971013359245 1,371571073383262;
[fractal_1]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_scale 3;
[fractal_2]
[fractal_3]
[fractal_4]
[fractal_5]
[fractal_6]
[fractal_7]
[fractal_8]
[fractal_9]


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on June 26, 2016, 03:16:05 AM
Thanks I  will try that.

This formula/concept is so cool. Just testing the base shape for the few days has been a lot of fun, it works so well with many linear type formulas creating all sorts of new shapes for me.


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on July 02, 2016, 02:53:22 AM
Latest c++ version of the prism shape transform.  I have made one UI where the set up has transforms :- PrismShape, Benesi T1, Benesi T1 Mod, Menger Sponge (all have start/stop iterations controls.)
The prism shape has now got four internal parameters, when mixed with the other transform internal parameters, the possibilities appear to approximate infinity :dink:.






Code:
/**
 * Menger Prism Shape
 * from code by Knighty http://www.fractalforums.com/fragmentarium/cross-menger!-can-anyone-do-this/msg93972/#new
 */
void MengerPrismShapeIteration(CVector3 &z, int i, const cFractal *fractal)
{
  CVector3 gap = fractal->transformCommon.constantMultiplier000; // default 0,0,0
  double t;
  double temp;
  double sqr3 = SQRT_3;
  double sqr305 = 0.86602540378443864676372317075294;
  double dot1;

  if ( i >= fractal->transformCommon.startIterationsA // default 0.0
     && i < fractal->transformCommon.stopIterations1)// default 1.0
  {
    z.y = fabs(z.y);
    z.z = fabs(z.z);
    dot1 = (z.x * -sqr305 + z.y * 0.5) * fractal->transformCommon.scale; // default 1
    t = max(0.0, dot1);
    z.x -= t * -sqr3;
    z.y = fabs(z.y - t);

    if(z.y > z.z)
    {
      temp =z.y;
      z.y = z.z;
      z.z = temp;
    }
    z -= gap * CVector3( sqr305, 1.5, 1.5);
    // 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;
    }
    if(z.x < 0.0 )
    {
      z.x = z.x;
    }
    else
    {
      z.y = max(0.0, z.y);
      z.z = max(0.0, z.z);
    }
  }
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: Buddhi on July 04, 2016, 09:01:06 PM
No!  ;D
(the N in No stans for No) ;)

BTW, you can get the KIFS version without coding in mandelbulber.
Code:
# Mandelbulber settings file
# version 2.07
# only modified parameters
[main_parameters]
aux_light_enabled_1 true;
aux_light_intensity_1 1,41254;
aux_light_position_1 5 -3 3;
camera 3,365672583055189 -3,804478575040412 2,714269048418577;
camera_distance_to_target 2,604907989501952;
camera_rotation 25,86963147804066 -31,02749091811327 -1,416340756589222e-13;
camera_top -0,2249033775581471 0,4637956897721983 0,8569200831534224;
formula_1 10;
keyframe_last_to_render 0;
main_light_intensity 1,07;
target 2,391708951148566 -1,795971013359245 1,371571073383262;
[fractal_1]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_scale 3;
[fractal_2]
[fractal_3]
[fractal_4]
[fractal_5]
[fractal_6]
[fractal_7]
[fractal_8]
[fractal_9]

You are GENIUS! I have never mastered how to define all vectors intentionally. It is always mostly experimenting. I can write the software, but don't know how to use it  :headbatting:


Title: Re: Cross Menger!? Can anyone do this?
Post by: Buddhi on July 04, 2016, 10:05:44 PM
By the way, it's very nice starting point to get interesting shapes:

Code:
# Mandelbulber settings file
# version 2.08
# only modified parameters
[main_parameters]
aux_light_enabled_1 true;
aux_light_intensity_1 1,41254;
aux_light_position_1 5 -3 3;
basic_fog_color f100 f100 e500;
basic_fog_enabled true;
basic_fog_visibility 3,46737;
brightness 1,67;
camera -1,805545920848823 0,7293700491624603 -2,397988757052514;
camera_distance_to_target 0,006226014714202337;
camera_rotation -150,0427711170006 35,45873861972266 91,66986964501579;
camera_top -0,8575889311327257 -0,5137877264398242 -0,0237359928889756;
DE_thresh 7,4131e-07;
DOF_enabled true;
DOF_focus 0,002681433456018567;
DOF_radius 4,43;
flight_last_to_render 0;
fog_color_1 ff00 e200 0000;
fog_color_2 7e00 6700 2400;
fog_color_3 af00 a200 8a00;
formula_1 10;
gamma 0,74;
image_height 2160;
image_width 3840;
keyframe_last_to_render 0;
main_light_alpha -73,3;
main_light_beta 22,83;
main_light_intensity 1,07;
mat1_coloring_random_seed 133572;
mat1_coloring_saturation 0,14;
mat1_surface_color_palette 786b7b 3d3e2b 4d353a 62556e 4a333e f3e6f5 182110 877c97 424c48 ddcdc8;
raytraced_reflections true;
shadows_cone_angle 0,1;
target -1,803013551299897 0,7249762850259339 -2,394376943048206;
view_distance_max 27,84953095615215;
volumetric_fog_colour_1_distance 0,0001761009087797636;
volumetric_fog_colour_2_distance 0,0003522018175595273;
volumetric_fog_distance_factor 0,0003522018175595273;
volumetric_fog_enabled true;
[fractal_1]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_rotation -32,9 0 90;
IFS_rotation_enabled true;
IFS_scale 3;
[fractal_2]
[fractal_3]
[fractal_4]
[fractal_5]
[fractal_6]
[fractal_7]
[fractal_8]
[fractal_9]



Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on July 05, 2016, 06:11:16 AM
@ buddhi, I was impressed too!!!   

The prism shape is a lot of fun and has introduced another fast shape into the mix. I am thinking we could add this (and probably others to the presets on the kifs UI.)




Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on July 05, 2016, 06:32:19 PM
The prism shape is a lot of fun and has introduced another fast shape into the mix. I am thinking we could add this (and probably others to the presets on the kifs UI.)
Can you show on GLSL how you doing this?  :embarrass:


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on July 05, 2016, 08:43:08 PM
Here is an attempt :)

It is essentially the first part of Knighty's code with the differences in  yellow and used  generally as a  pre transform.  The simplest example is place it before a menger sponge and test out the gap and dotscale parameters. For the above image I placed it before the existing KIFS version that Knighty showed was already possible in Mandelbulber.


Code:
#info CrossMenger
#include "DE-Raytracer.frag"
#group CrossMenger
// Number of fractal iterations.
uniform int Iterations;  slider[0,3,100]
uniform vec3 Gap; slider[-1.,0.,1.]
uniform float dotscale; slider[0.,1.,5.]
uniform float Dot KIFS; checkbox[false]


float baseshape(vec3 p, float gap)

{
        p.yz=abs(p.yz);

        float t = 2.* max(0., dotscale * 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-=gap *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 (p );
}

oops yellow hard to read

Code:
Code:
#info CrossMenger
#include "DE-Raytracer.frag"
#group CrossMenger
// Number of fractal iterations.
uniform int Iterations;  slider[0,3,100]
uniform vec3 Gap; slider[-1.,0.,1.]
uniform float dotscale; slider[0.,1.,5.]
uniform float Dot KIFS; checkbox[false]


float baseshape(vec3 p, float gap)

{
        p.yz=abs(p.yz);

        float t = 2.* max(0., dotscale * 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-=gap *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 (p );
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: Max Sinister on July 05, 2016, 11:15:36 PM
Very nice. I may have to get this software one day.


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on July 06, 2016, 06:05:39 AM
Quote
Can you show on GLSL how you doing this?  embarrass

This is what the default settings should give you if you run Prism Shape for one iteration, followed by a standard Menger Sponge for the remaining iterations.

The dotscale simply flattens the shape  i.e a house with roof shape.

With the Gap x,y,z controls you get some cool shapes  with symmetric gap vect3 like (0.5, -0.5,  0.0)

In Mandelbulber I have iteration controls  so I can place the Prism Shape Transform  at "say" iteration number 2 , or iterations 2 & 3.

If you can get this to work I can do some more  GLSL-ish code for the other transforms that work well together with the prism base shape.




Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on July 06, 2016, 06:46:54 AM
This is what gap vect3 (0.5, -0.5, 0.0) should look like :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: knighty on July 12, 2016, 12:12:47 AM
It is not that difficult to do KIFS. It requires some work though and a lot of sketches (and maybe a 3D CAD software). It is better to begin with 2D objects. The first one I did was a 2D Sierpinski triangle :)

One have to:
- Identify scale center and value.
- Identify the folding lines/planes and their order: These are visible as the object is symmetric.

Here is the settings for the KIFS version of the crossMenger with 3 iterations (can be changed). The second KIFS formula is for the prism:
Code:
# Mandelbulber settings file
# version 2.08
# only modified parameters
[main_parameters]
ambient_occlusion 5;
ambient_occlusion_enabled true;
ambient_occlusion_mode 1;
bailout 208,93;
camera -0,5069504723639101 -3,94725606567745 2,514460444670165;
camera_distance_to_target 3,766618844714503;
camera_rotation -7,318497517213343 -32,28573138251144 -1,391989634809267e-13;
camera_top 0,06804156545685146 0,529790377184933 0,8453948791023207;
check_for_bailout_1 false;
delta_DE_function 1;
detail_level 2;
file_lightmap C:\Documents and Settings\Administrateur\Mes documents\Téléchargements\mandelbulber2-win32-2.08-1\textures\background4.jpg;
flight_last_to_render 0;
formula_1 71;
formula_2 10;
formula_3 10;
formula_iterations_2 3;
formula_material_id 3;
formula_stop_iteration_3 100;
fractal_enable_1 false;
glow_enabled false;
hybrid_fractal_enable true;
image_height 480;
image_width 640;
keyframe_last_to_render 0;
mat1_is_defined true;
mat2_fresnel_reflectance true;
mat2_is_defined true;
mat2_name gold;
mat2_reflectance 0,72;
mat2_specular 5;
mat2_specular_color ff00 e100 3400;
mat2_specular_width 0,215;
mat2_surface_color ff00 cc00 1000;
mat2_transparency_index_of_refraction 10;
mat2_use_colors_from_palette false;
mat3_is_defined true;
mat3_name red plastic;
mat3_specular 1,08;
mat3_specular_width 0,343;
mat3_surface_color a700 1300 1300;
mat3_transparency_index_of_refraction 1,37;
mat3_use_colors_from_palette false;
mat4_is_defined true;
mat4_name white plastic;
mat4_surface_color 6f00 6f00 6f00;
mat4_use_colors_from_palette false;
N 98;
penetrating_lights false;
primitive_plane_1_enabled true;
primitive_plane_1_material_id 4;
primitive_plane_1_position 0 0 -1,5;
repeat_from 3;
SSAO_random_mode true;
target -0,1013214770768532 -0,788916939183583 0,5025517485314003;
use_default_bailout false;
volumetric_fog_colour_1_distance 0,7849368203977499;
volumetric_fog_colour_2_distance 1,5698736407955;
volumetric_fog_distance_factor 1,5698736407955;
[fractal_1]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_rotation 38,35 0 0;
IFS_scale 3;
power 8;
transf_constant_multiplier_441 3 3 3;
transf_rotation 60 0 80,2;
transf_scale -1;
[fractal_2]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_rotation 38,35 0 0;
IFS_scale 3;
power 8;
[fractal_3]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0,5 0,866 0;
IFS_distance_2 0,43;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_offset 0,866 1,5 1,5;
[fractal_4]
[fractal_5]
[fractal_6]
[fractal_7]
[fractal_8]
[fractal_9]

And this one with a "reduced" prism. I have just scaled down (in the second KIFS) the "vector offset" and the "dist" of the #3 folding vector:
Code:
# Mandelbulber settings file
# version 2.08
# only modified parameters
[main_parameters]
ambient_occlusion 0,27;
ambient_occlusion_enabled true;
ambient_occlusion_mode 0;
bailout 208,93;
camera -0,5069504723639101 -3,94725606567745 2,514460444670165;
camera_distance_to_target 3,766618844714503;
camera_rotation -7,318497517213343 -32,28573138251144 -1,391989634809267e-13;
camera_top 0,06804156545685146 0,529790377184933 0,8453948791023207;
check_for_bailout_1 false;
delta_DE_function 1;
detail_level 2;
file_lightmap C:\Documents and Settings\Administrateur\Mes documents\Téléchargements\mandelbulber2-win32-2.08-1\textures\background4.jpg;
flight_last_to_render 0;
formula_1 71;
formula_2 10;
formula_3 10;
formula_iterations_2 3;
formula_material_id 3;
formula_stop_iteration_3 100;
fractal_enable_1 false;
glow_enabled false;
hybrid_fractal_enable true;
image_height 480;
image_width 640;
keyframe_last_to_render 0;
mat1_is_defined true;
mat2_fresnel_reflectance true;
mat2_is_defined true;
mat2_name gold;
mat2_reflectance 0,72;
mat2_specular 5;
mat2_specular_color ff00 e100 3400;
mat2_specular_width 0,215;
mat2_surface_color ff00 cc00 1000;
mat2_transparency_index_of_refraction 10;
mat2_use_colors_from_palette false;
mat3_is_defined true;
mat3_name red plastic;
mat3_specular 1,08;
mat3_specular_width 0,343;
mat3_surface_color a700 1300 1300;
mat3_transparency_index_of_refraction 1,37;
mat3_use_colors_from_palette false;
mat4_is_defined true;
mat4_name white plastic;
mat4_surface_color 6f00 6f00 6f00;
mat4_use_colors_from_palette false;
N 98;
penetrating_lights false;
primitive_plane_1_enabled true;
primitive_plane_1_material_id 4;
primitive_plane_1_position 0 0 -1,5;
repeat_from 3;
SSAO_random_mode true;
target -0,1013214770768532 -0,788916939183583 0,5025517485314003;
use_default_bailout false;
volumetric_fog_colour_1_distance 0,7849368203977499;
volumetric_fog_colour_2_distance 1,5698736407955;
volumetric_fog_distance_factor 1,5698736407955;
[fractal_1]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_rotation 38,35 0 0;
IFS_scale 3;
power 8;
transf_constant_multiplier_441 3 3 3;
transf_rotation 60 0 80,2;
transf_scale -1;
[fractal_2]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0 -0,707 0,707;
IFS_direction_3 0 1 0;
IFS_distance_3 0,5;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_enabled_3 true;
IFS_offset 0,866 1,5 1,5;
IFS_rotation 38,35 0 0;
IFS_scale 3;
power 8;
[fractal_3]
IFS_abs_y true;
IFS_abs_z true;
IFS_direction_0 0,866 -0,5 0;
IFS_direction_1 0 1 0;
IFS_direction_2 0,5 0,866 0;
IFS_distance_2 0,34;
IFS_enabled_0 true;
IFS_enabled_1 true;
IFS_enabled_2 true;
IFS_offset 0,6929999999999999 1,2 1,2;
[fractal_4]
[fractal_5]
[fractal_6]
[fractal_7]
[fractal_8]
[fractal_9]


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on July 13, 2016, 12:15:50 PM
Thanks Knighty for the  settings.

DarkBeam sidetracked me away from this, with a single line transform _inv_cylindrical. Instead of it being  a quick diversion, it turned into yet another journey of discovery :) O0

I  have been thinking about kifs and linear type folds in general,  and now can visualize the mega UI that I will probably never build.

When I was still using MandelbulberV1.21 openCL, I did a little bit of drawing up and it makes it easier to visualize. This reminded me to have another look at that code :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on August 18, 2016, 02:48:36 PM
I have got "some sort" of pseudo kleinian code working with the prism shape and menger sponge in dev V2.09. Early days yet. :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: M Benesi on August 19, 2016, 02:50:02 AM
lol  :D


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on August 31, 2016, 06:30:06 AM
(http://pre12.deviantart.net/4ec2/th/pre/f/2016/243/5/7/glass_bunch_by_crist_jroger-dag1w5z.jpg) (http://orig11.deviantart.net/7f81/f/2016/243/5/7/glass_bunch_by_crist_jroger-dag1w5z.jpg)


Title: Re: Cross Menger!? Can anyone do this?
Post by: 3dickulus on August 31, 2016, 06:32:19 AM
Spring thaw, very nice, refreshing and crispy :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on August 31, 2016, 09:08:14 AM
Thank you very much  :dink: Originally it was this (http://crist-jroger.deviantart.com/art/Water-sphere-631542194), then moved camera top and looked at water only ) and change sphere to fractal


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on September 09, 2016, 10:44:54 AM
I added the pure kifs version in mb3d 8D


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on September 15, 2016, 12:58:56 PM
A modification thing.


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on September 15, 2016, 01:12:20 PM
shared .frag?  :embarrass:  :dink:


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on September 16, 2016, 06:51:42 AM
This is an attempt at the formula part of a .frag.  (I don't know enough yet about programming for fragmentarium)

If you can get it to work, please post back the corrected .frag so i can see my mistakes.

I have been using it to make hybrids with aSurf, pseudoKlienianMod, and MengerMods

This image is with gap.y set at 1.99, the rest of parameters at default.

Code:
#info CrossMengerMod1
#include "DE-Raytracer.frag"
#group CrossMenger

// Number of fractal iterations.
uniform float Scale; slider[0.,1.,2.]
uniform float ScaleY; slider[0.,1.,2.]
uniform float ScaleZ; slider[0.,1.,2.]
uniform int iter; slider[0, 12, 250}
uniform float3 gap; slider[(-1.,-1.,-1.),(0.,0.,0.),(3.,2.,3.]  gap = offset scale,
uniform bool Mod; checkbox[false] // this works only with some settings

const float SQRT_3_4  = 0.86602540378443864676372317075294;
const float SQRT_3 =  1.73205080756887729352744634150587;
float t;
float temp;
float dot1;
const float DE = 1.0;
const float Bailout = 10.0;
vec3 z = p;

uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)]
uniform float RotAngle; slider[0.00,0,180]
mat3 rot;
void init() {
rot = rotationMatrix3(normalize(RotVector), RotAngle);
}

void CrossMengerMod1( vec3 z)
{
    z.z = abs(z.z);
    dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * Scale;
    t = max(0.0, dot1);
    z.x -= t * -SQRT_3 - (0.5 * SQRT_3_4);
    z.y = abs(z.y - t);

    if (z.y > z.z)
    {
      temp = z.y;
      z.y = z.z;
      z.z = temp;
    }
    z.y -=  1.5;
    z -= gap * vec3(SQRT_3_4, -1.5, 1.5);

    if (z.z > z.x)
    {
      temp = z.z;
      z.z = z.x;
      z.x = temp;
    }
    if(Mod)
    {
      if (z.x >= 0.0)
      {
        z.y = max(0.0, z.y) * ScaleY;
        z.z = max(0.0, z.z) * ScaleZ;
      }
    z *= rot;
    }

 
   for(int i=0; i< iter; i++)
 
   { // CrossMengerTrick
     z.y = abs(z.y);
     z.z = abs(z.z);
     dot1 = (z.x * -SQRT_3_4 + z.y * 0.5);
     float t = 1 * max(0.0, dot1);
     z.x -= t * -SQRT_3;
   
     z.x -= SQRT_3_4;

    float dy = 0.0;
    float dz = 0.0;
    if (z.y > 0.5 && z.z > 0.5)
    {
      dy = 1.5;
      dz = 1.5;
    }
    else if
        ((z.y - 1.5) * (z.y - 1.5) + z.z * z.z < z.y * z.y + (z.z - 1.5) * (z.z - 1.5))
    {
      dy = 1.5;
    }
    else
      dz = 1.5;

    z.y -= dy;
    z.z -= dz;
    z *= 3.0;
    DE *= 3.0;
    z.y += dy;
    z.z += dz;

    z.x += SQRT_3_4;

    r = length(z);
    if ( r > Bailout)
    return ( r - 2.) / DE;
  }
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on September 17, 2016, 08:59:06 PM
Thank you! I tried to make this code working... so here some strange  :o it shows little different geometry ) but it runs  :embarrass:
Code:
#info CrossMengerMod1
#include "MathUtils.frag"
#include "DE-Raytracer.frag"
#group CrossMenger

// Number of fractal iterations.
uniform float Scale; slider[0.,1.,2.]
uniform float ScaleY; slider[0.,1.,2.]
uniform float ScaleZ; slider[0.,1.,2.]

uniform int Iter; slider[0,12,250]

uniform vec3 gap; slider[(-1.,-1.,-1.),(0.,0.,0.),(3.,2.,3.)]
uniform bool Mod; checkbox[false]


const float SQRT_3_4  = 0.86602540378443864676372317075294;
const float SQRT_3 =  1.73205080756887729352744634150587;
float t;
float temp;
float dot1;
//const float DE = 1.0;
const float Bailout = 10.0;
//vec3 z = p;

uniform vec3 RotVector; slider[(0,0,0),(1,1,1),(1,1,1)]
uniform float RotAngle; slider[0.0,0,180]
mat3 rot;


float DE(vec3 z) {
 rot = rotationMatrix3(normalize(RotVector), RotAngle);
z.z = abs(z.z);
dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * Scale;
t = max(0.0, dot1);
z.x -= t * -SQRT_3 - (0.5 * SQRT_3_4);
z.y = abs(z.y - t);
if (z.y > z.z) {
temp = z.y;
z.y = z.z;
z.z = temp;
}


z.y -=  1.5;
z -= gap * vec3(SQRT_3_4, -1.5, 1.5);
if (z.z > z.x) {
temp = z.z;
z.z = z.x;
z.x = temp;
}
if(Mod) {
if (z.x >= 0.0) {
z.y = max(0.0, z.y) * ScaleY;
z.z = max(0.0, z.z) * ScaleZ;
}
z *= rot;
}


for(int i=0; i< Iter; i++) { // CrossMengerTrick
    z.y = abs(z.y);
    z.z = abs(z.z);
    dot1 = (z.x * -SQRT_3_4 + z.y * 0.5);
    float t = 1. * max(0.0, dot1);
    z.x -= t * -SQRT_3;
    z.x -= SQRT_3_4;
    float dy = 0.0;
    float dz = 0.0;
if (z.y > 0.5 && z.z > 0.5) {
dy = 1.5;
dz = 1.5;
}
else if ((z.y - 1.5) * (z.y - 1.5) + z.z * z.z < z.y * z.y + (z.z - 1.5) * (z.z - 1.5)) {
dy = 1.5;
    }
else
dz = 1.5;
z.y -= dy;
z.z -= dz;
z *= 3.0;
float DE1=1.0;
DE1*= 3.0;
z.y += dy;
z.z += dz;
z.x += SQRT_3_4;
z = length(z);
//if (z > Bailout)
return ( z- 2.) / DE1;
  }

}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on September 18, 2016, 02:06:38 AM
Thanks, I now have a better understanding of  .frag.

I will code it up in Mandelbulber V1.21 OpenCL  and see what I get and report back.

The important bit is the first half , which gives you control over the prism shape, you can replace the crossmengertrick with iterations of other linear types


Title: Re: Cross Menger!? Can anyone do this?
Post by: Tim Emit on September 19, 2016, 10:36:20 AM
@crist.. that code runs ok as far as shapes  but it doesn't seem to iterate or make much interesting forms...or is that just me !


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on September 19, 2016, 06:15:59 PM
The important bit is the first half , which gives you control over the prism shape, you can replace the crossmengertrick with iterations of other linear types
Unfortunately I can't. Not yet I think  ;D because all GLSL-guru escaped :-\ and maybe soon I will be able to understand this interesting process: imagine - create a mathematical model - implement the code  :)

Tim my code is wrong (but runs without errors) Somebody (Knighty, where are you????  ;D ) can help.


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on September 20, 2016, 09:40:58 AM
The formula  can make the attached image, (but there is an extra bit on the far end :o I have lost the symmetry).  More work required!


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on September 26, 2016, 09:34:16 AM
A finally coded the KIFS version ;D


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on September 28, 2016, 04:09:31 PM
Looks like robot or constructor  :)

CrossMenger in PseudoKleinian:
(http://pre10.deviantart.net/272a/th/pre/f/2016/272/1/a/to_the_sun_by_crist_jroger-daj9s5z.jpg)  (http://orig11.deviantart.net/ddec/f/2016/272/1/a/to_the_sun_by_crist_jroger-daj9s5z.jpg)


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on October 05, 2016, 03:53:01 PM
Shared PseudoKleinian-CrossMenger hybrid (http://crist-jroger.deviantart.com/art/PseudoKleinian-CrossMenger-for-Fragmentarium-638363685)


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on October 07, 2016, 01:45:14 AM

//  This is the simplest version of Knighty prismshape that I have used as a pre-transform in several formula UI's
// I forgot to add the Xcondition checkbox in the PrismShapeOption.frag i posted yesterday

const float SQRT_3_4  = 0.86602540378443864676372317075294;
const float SQRT_3 =  1.73205080756887729352744634150587;
uniform vec3 offsetScale; slider[(-1,-1,-1),(0,0,0),(1,1,1)]
uniform float dotScale; slider[0.0,1.0,2.0]
uniform bool PrismShape; checkbox[true]
uniform bool Xcondition; checkbox[true]




   if (PrismShape) { // a pre-transform, no DE required
      z = vec3({z.z, z.x, z.y); // reorientate

      z.z = abs(z.z);      
      float dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * dotScale; 
      float t = max(0.0, dot1);
      z.x -= t * -SQRT_3;
      z.y = abs(z.y - t);
      if(z.y > z.z){ temp =z.y; z.y = z.z;   z.z = temp;}
      z -= offsetScale * vec3{ SQRT_3_4, 1.5, 1.5}; 
      if(z.z > z.x){temp =z.z; z.z = z.x; z.x = temp;}

      if (Xcondition) {
         if(z.x >= 0.0){ z.y = max(0.0, z.y); z.z = max(0.0, z.z);}
      }
   }

// then iterate a menger sponge

// when dotScale = 2.0 ,  is standard house shape
// when offset scale = (-0.5, 0, 0),  is the prism shape (for this version)
// X Condition. With some settings parts of the fractal become "extrusions", if this is not wanted then untick this checkBox


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on October 07, 2016, 09:04:11 AM
... in the PrismShapeOption.frag i posted yesterday
Where?  :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on October 07, 2016, 11:06:12 AM
I hid it here ;D
http://www.fractalforums.com/images-showcase-(rate-my-fractal)/spires-t24633/msg96518/#new (http://www.fractalforums.com/images-showcase-(rate-my-fractal)/spires-t24633/msg96518/#new)

It  has just been inserted into 3dickulus's   .frag, so probably need to zoom out at first

I  was re-learning this prism thing yesterday. This is the version that makes the house shape.

You can add this to the Prism Shape pre-transform (openCL code)

z *= postScale;//  vect3 default (1,1,1)
z = Matrix33MulFloat3(consts->fractal.mandelbox.mainRot, z); // rotations


and this is the formula code inside the  menger sponge iteration loop

Code:
//PreAdd and Knighty MengerSponge
z = fabs( z + preAdd ); // preadd default (0,0,0)
if (z.x - z.y < 0.0f){temp = z.y; z.y = z.x; z.x = temp;}
if (z.x - z.z < 0.0f){temp = z.z; z.z = z.x; z.x = temp;}
if (z.y - z.z < 0.0f){temp = z.z; z.z = z.y; z.y = temp;}
z *= mengerScale; // default 3
z.x -= 2.0f;
z.y -= 2.0f;
if (z.z > 1.0f) z.z -= 2.0f;
DE *= mengerScale;


//postAddition
z =  z  + postAdd; // postAdd default (0,0,0)
// make it hollow
z.x = fabs(z.x + tempA) + tempB;  // defaults float 0 and 0,  something like  1 and -1 will make the mengerSponge  hollow

if (negY == 1) // turning on a tweak that works depending  on other parameters are set to.
{z.y = -z.y;

}

and
// bailout termination
if (r > 10.0f) //bailout
    {
      dist = r / fabs(DE);
      out.colourIndex = colourMin * 10.0f;
      break;
   }







Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on October 29, 2016, 06:17:52 AM
Latest version of crossmenger trick

Adding in the fabs(z.x) option provides another ... eh.. option.
The derivative scale thingy is a beta thingy, that can work in some hybrid situations.

Images below are with a dotscale of 0.2,   and with and without fabs(z.x)

#define SQRT_3_4 0.86602540378443864676372317075294
#define SQRT_3 1.73205080756887729352744634150587

Code:
	if (crossMengerTrickEnabled
&& i >= startIterations
&& i < stopIterations)

{ // CrossMengerTrick. Tweaks on Knighty_Maths
double dd = DE;
z.y = fabs(z.y);
z.z = fabs(z.z);
if ( FabsZEnabled)
{
z.x = fabs(z.x);
}

dot1 = ( z.x * -SQRT_3_4 + z.y * 0.5 ) * DotScale;
double t = max(0.0, dot1);
z.x -= t * -SQRT_3;

if (Mod1Enabled)
{
z.y = fabs(z.y) - t;
}
else
{
z.y = fabs(z.y - t);
}
z.x -= SQRT_3_4;
double dy = 0.0;
double dz = 0.0;
if (z.y > 0.5 && z.z > 0.5)
{
dy = 1.5;
dz = 1.5;
}
else if ((z.y - 1.5) * (z.y - 1.5) + z.z * z.z < z.y * z.y + (z.z - 1.5) * (z.z - 1.5))
{
dy = 1.5;
}
else
dz = 1.5;

z.y -= dy;
z.z -= dz;
z *= MengerScale;
DE *= MengerScale;
z.y += dy;
z.z += dz;
z.x += SQRT_3_4;

if (DerivativeScaleEnabled)
{
dd *=  DerivativeScale;
z *= dd;
aux.DE *= dd;
}
DE *= DEtweak;
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on October 29, 2016, 08:38:37 AM
And the dotScale can even go negative in some situations. Bringing the parameter to -0.1 has made this shape hollow.


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on October 31, 2016, 12:43:52 AM
These images have an exp2 transform used for 2 or 3 iterations. 

In brief;  This transform can be used with most standard type formulas (but can be a bit tricky to use.)

we are modifying  so that     z = z + a_proportion _of exp2(z.x)

Here is the beginning code,  repeat for y and z. (even though there is no DE calc, I also insert a DE tweak at the end which can help)
Code:
		CVector3 tempZ = z;

if (fractal->transformCommon.functionEnabledx) // enable exp2(z.x)
{
if (fractal->transformCommon.functionEnabledAx) // enable fabs (z.x)
{
tempZ.x = fabs(z.x);
if (fractal->transformCommon.functionEnabledAxFalse) //  enable if you want to use the flatter negative part of the pow curve
{
tempZ.x = -tempZ.x;
}
tempZ.x = exp2(tempZ.x * fractal->transformCommon.constantMultiplier000.x) - 1.0;
if (z.x > 0)
z.x += tempZ.x;
else
z.x -= tempZ.x;
}
else
z.x += exp2(tempZ.x * fractal->transformCommon.constantMultiplier000.x) - 1.0;
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on October 31, 2016, 10:32:45 AM
Exp is too strong as deform and slows de :(
You should use a polynome valid in range -1 to 1 then extend it with some linear expression. :D
Or try to use my reciprocalx3 it is a rational polynomial that never goes to infinity.


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 01, 2016, 02:36:05 AM
@darkbeam

thanks, I will code up  the reciprocalx3 type.  "Deform" is the word I have been looking for  :),  the parameter tweaking iteration_count  stuff, that I have also been working on are "deformers".


The main reason behind the exp2 transform is that apparently I once made the attached image out of a mandelbox with some exp2 working on one axis, and I want to recreate it to find out how it worked.


 


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 03, 2016, 02:06:23 AM
Well Reciprocal3 has got me sidetracked :D  I even graphed it.  And I am now getting a SIGN()  function added to the Mandelbulbers maths

Here it is for a single iteration to deform the cross menger trick,    Image 001 running at iteration 0, and then image 002 at iteration 1 (after the first crossmenger trick iteration ) in the hybrid loop.


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on November 03, 2016, 08:07:38 AM
Woow it looks nice :D in mb3d sometimes it stretches fractals to the infinity. There are versions also for y and z that do very different things on kifs fractals (that do intense coord swapping) like Menger, Sierpinski SierpHilbert etc... :D and usually it is alternated for every iter to get strange futuristic buildings.


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on November 07, 2016, 09:33:47 AM
Code:
const float SQRT_3_4  = 0.86602540378443864676372317075294;
const float SQRT_3 =  1.73205080756887729352744634150587;
uniform vec3 offsetScale; slider[(-1,-1,-1),(0,0,0),(1,1,1)]
uniform float dotScale; slider[0.0,1.0,2.0]
uniform bool PrismShape; checkbox[true]
uniform bool Xcondition; checkbox[true]

if (PrismShape) { // a pre-transform, no DE required
z = vec3({z.z, z.x, z.y); // reorientate

z.z = abs(z.z);
float dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * dotScale;  
float t = max(0.0, dot1);
z.x -= t * -SQRT_3;
z.y = abs(z.y - t);
if(z.y > z.z){ temp =z.y; z.y = z.z; z.z = temp;}
z -= offsetScale * vec3{ SQRT_3_4, 1.5, 1.5};  
if(z.z > z.x){temp =z.z; z.z = z.x; z.x = temp;}

if (Xcondition) {
if(z.x >= 0.0){ z.y = max(0.0, z.y); z.z = max(0.0, z.z);}
}
}

error?
z = vec3({z.z, z.x, z.y); // reorientate
Can you see my .frag? What's wrong?

Tried another code from your latest posts, what is fabs? Did you used Fragmentarium?


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on November 07, 2016, 05:25:02 PM
Just found ChebyMenger from an Eiffie shadertoy! Lool, fantastic ;D

Code:
/// Chebymenger by eiffie

#define Pi 4.0
float Cos(float a){return clamp(abs(mod(a,2.0*Pi)-Pi)-Pi/2.0,-1.0,1.0);}
float Sin(float a){return Cos(a-Pi/2.0);}
vec2 CosSin(float a){return vec2(Cos(a),Sin(a));}
float Length(vec2 p){return max(abs(p.x),abs(p.y));}//==(x^inf+y^inf)^(1/inf)
float Length(vec3 p){return max(abs(p.x),max(abs(p.y),abs(p.z)));}
float Atan(vec2 p){
if(p.y==0.0)return (p.x>0.0?0.0:4.0);
float a=p.x/p.y;
if(abs(a)<1.0){
if(p.y>0.0)return 2.0-a;
else return 6.0-a;
}else {
a=p.y/p.x;
if(p.x>0.0)return mod(a,8.0);
else return 4.0+a;
}
}
vec2 Rotate(vec2 p,float a){return CosSin(Atan(p)+a)*Length(p);}

const int iters=4;
float psni=pow(3.0,-float(iters)),tym=iGlobalTime;
float DE(in vec3 p){//menger with chebyshev rotation
p.xy=Rotate(p.xy,tym);
//p.xz=Rotate(p.xz,tym);//for more weirdness
for (int n = 0; n < iters; n++) {
p = abs(p);
if (p.x<p.y)p.xy = p.yx;
if (p.x<p.z)p.xz = p.zx;
if (p.y<p.z)p.yz = p.zy;
p = p*3.0 - 2.0;
if(p.z<-1.0)p.z+=2.0;
}
return (Length(p)-1.0)*psni*0.707;//.707 compensates for the square rotation
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 08, 2016, 02:40:54 AM
@ Crist

quote]Tried another code from your latest posts, what is fabs? Did you used Fragmentarium?[/quote

In openCL and C++ I have a fabs() which is abs() in most frags I have seen. Not sure if it a maths library thingy. And I have still haven’t learnt how to use fragmentarium:)

Quote
z = vec3({z.z, z.x, z.y); // reorientate
Yep, I dont know how that got there. I should really transpose the axis in the formula so that the reorientation wouldn’t be necessary.

Missing a z.y = abs(z.y);  before the    z.z = abs(z.z);      

also can add in a z.x = abs(z.x);  option checkbox.


BTW This is where I am up to this coding:

a) I  have written a fourth version of the PrismShape, it does all of what my first three attempts can do plus more. I will post this with an explanation of converting Mandelbulber code into .frag.
b) The CrossMenger Trick  i posted here on the 29th is my final version of that one.
c) I have yet to do a final CrossMengerKIFS version

PS you can replace
if(z.z > z.x){temp =z.z; z.z = z.x; z.x = temp;} type code
with
if(z.z > z.x){z.xz = z.zx;} in Fragnmentarium (and in openCL)

PPS  looking at the zipped file. As well as the prismShape code , you can add a dotScale to the dot in both the CrossMengerTrick and CrossMengerKIFS.

 


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 08, 2016, 04:20:19 AM
I have finished coding Darkbeams reciprocal3 x, y, and z. ( I have still got to get a SIGN() function code to work for optimising this code.)
 Here is Darkbeams code

Quote
Description:

Computes the reciprocal of x with a different (continuous) function:

x' = sign(x)(1/Lim - 1/(abs(x)+ Lim ))


The DE is almost untouched, it should work fine also with a Raystep 0.5 !
Just don't go too low with the limiter to avoid noise.

In Mandelbulber I have it set up this way at present. I have the default parameters at 1.0 but 0.5 might be better in most cases. Hmmm

Here is the z.x part. Start/stop iteration controls are also necessary. The transform can be run on all three axis  until termination but  using  1 or 2 axis  for  only a few iterations is generally best, starting at iteration 0 or iteration1.  (It works well with the menger types but I suspect surf/box types is where this transform maybe at it's best).  

Covert from Mandelbulber to .frag:

if (fractal->transformCommon.functionEnabledx) type code is a checkBox
fractal->transformCommon.offset111.x) type code is a vec3 default(1,1,1) axis .x
fabs is abs

Code:
		if (fractal->transformCommon.functionEnabledx)
{
if (fractal->transformCommon.functionEnabledAx)
tempZ.x = (1.0 / fractal->transformCommon.offset111.x) - 1.0 / (fabs(z.x) + fractal->transformCommon.offset111.x);

if (fractal->transformCommon.functionEnabledAxFalse)
tempZ.x = (fractal->transformCommon.offsetA111.x) - 1.0 / (fabs(z.x) + fractal->transformCommon.offset111.x);

tempZ.x += fabs(z.x) * fractal->transformCommon.offset000.x; // function slope

if (z.x > 0.0)
{
z.x = tempZ.x;
}
else
{
z.x = -tempZ.x;
}
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 08, 2016, 04:48:51 AM
@Darkbeam. I checked out  chebyshev rotation on the net.  O0

I have just starting on MixPinski   :)  :hmh: :hmh: :embarrass: :) ;D :hmh:  In a day or two I will probably seek some clarification ;D


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on November 08, 2016, 10:52:40 AM
hehe by the way I got an identical effect using a shorter formula (not three just one I think?). I called it ngon (and ngon2) but I don't remember how it works! :D lol
Maybe with a combo of "normal" atan2 and stuff...
But now I am curious about MPinski ;)
Sign(x) is normally a one line macro.
Or sgn(x)=x/abs(x) horrible! :D
Or you make some AND with sign mask then if it is 0 it is a positive number else a negative. Duh hackish stuff sorry :D
There are premade cakes in Stackoverflow too; http://stackoverflow.com/questions/1903954/is-there-a-standard-sign-function-signum-sgn-in-c-c
Btw I think you added too much stuff ... the mb3d counterpart is really a 1 line... :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: claude on November 08, 2016, 12:20:37 PM
my favourite version is: sign(x) = (x > 0) - (x < 0)


Title: Re: Cross Menger!? Can anyone do this?
Post by: Sabine on November 08, 2016, 05:29:44 PM
@Luca Is this THE _reciprocalX,...Y,... - ...Z3 you're all talking about??? And if yes... We can haz for Frag?  :love:


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on November 08, 2016, 05:35:01 PM
Lol Sabi! Yes it is but what do you mean? You can code it as a one line transform then add it after a menger iter :) ... easy for a basic programmer like you!
 :-* ;D


Title: Re: Cross Menger!? Can anyone do this?
Post by: Sabine on November 08, 2016, 08:02:21 PM
I never touched anything even remotely 'fractalesque' with basic in the last 30 years, I think, and what I did then was only very basic fractal stuff.
Basic I used in my work and later VScript and JScript (now Those are really hi-tec, I know!  rofl2) for simple eventlog readouts, replication-logs and other info for rapporting, WMI stuff, that kind thing, mostly r/w & string-modification-hell. And sometimes still write something small and handy or fun for at home. Ohh forgot: some LISP for Autocad in the jolly 90's, whahaha now that will come in handy :}
So really, Luca, trust me now and forever, I'm a total nitwit when it comes to fractals AND programming, honestly!!!  :'(

But will try nonetheless :dink: :-*



Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 09, 2016, 02:01:40 AM
@sabine02

Reciprocal3  x' = sign(x)((1/Lim - 1/(abs(x)+ Lim)  works best,
 including the linear slope    + (abs(x) * slope)       works well
adding a two limit mode works OK in some cases,  but can cause poor DE


@darkbeam & claude

template <typename T>
inline int sign(T val)
{
   return (T(0) < val) - (val < T(0));
}

is what Buddhi has added for me,although I currently cannot get it to work :)

With MixPinski "A strange but intriguing fractal",  progress stopped at 4D rotation,  :hmh:, is there any examples of how this is done??

Meanwhile, when looking at 4D rotation I came across the tesseract O0

https://en.wikipedia.org/wiki/Rotations_in_4-dimensional_Euclidean_space#/media/File:Tesseract.gif (https://en.wikipedia.org/wiki/Rotations_in_4-dimensional_Euclidean_space#/media/File:Tesseract.gif)

and I start wondering if this structure translation has been used in making a fractal?


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 09, 2016, 05:02:45 AM
CrossMengerTrick alternating with  rotateForward_fold_rotateBack (rotatedAbs, rotatedFolding & "rotatedMBoxFolding")


Title: Re: Cross Menger!? Can anyone do this?
Post by: Sabine on November 09, 2016, 09:04:50 AM
@mclarekin Thanks a lot :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on November 09, 2016, 09:56:07 AM
Dear mclarekin you may look at this shader for a reference ;)

https://www.shadertoy.com/view/llSSzc

It has xw yw and zw routines. I am sure MBulber already has a 3d rotation support ;)
You just modify routines accordingly. (A copypaste should do the job :D ).
The mixpinski itself is just a modded copypaste of Knighty Sierpinski fused with Menger but with one more dimension!


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 10, 2016, 03:05:07 AM
PrismShape for 1 iteration to deform crossmenger trick.

 This crude deformation is by replacing line in prismShape
         dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
by
         dot1 = (z.y * -SQRT_3 + z.z)     * fractal->transformCommon.scale;

@darkbeam. Answering two questions with one link, well done. :)

I recognise that 4D rotation from somewhere back then, it looks much simpler  now.

That tesseract is  hypnotizing/fascinating to watch.

Thanks again :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 12, 2016, 04:54:25 AM
This is the UI setup for darkbeams rotateForward_Fold_rotateBack,  that I have used to deform the CrossMengerTrick.  The UI only covers some of the possibilities. 

 Seems to work well with mandelbulbs too!


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 12, 2016, 04:57:12 AM
Here I have deformed the CrossMengerKIFS with Darkbeams tetra3D.


Title: Re: Cross Menger!? Can anyone do this?
Post by: DarkBeam on November 12, 2016, 08:59:06 AM
But isn't Tglad fold exactly the Mandelbox fold? Doh  :D
Aldo rotate back should only ripristinate coords multiplying by the same rot matrix as before but translated (switch rows with columns).
This is a nice framework for mostly every transformer imaginable though
🤓


Title: Re: Cross Menger!? Can anyone do this?
Post by: 3dickulus on November 12, 2016, 06:18:12 PM
@mclarekin me thinks FragM needs a mclarekin folder in the /Examples/ ;)


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on November 12, 2016, 09:12:56 PM
mclarekin, thank you for explanation! I found some time for fix .frag. Here rotated CM with prismshape and some modes for dotScale

(http://img13.deviantart.net/926b/i/2016/317/f/8/cm_prism_by_crist_jroger-daoa2an.jpg) (http://orig03.deviantart.net/9c85/f/2016/317/e/a/cm_prism_by_crist_jroger-daoa2an.jpg)

(http://img09.deviantart.net/2d52/i/2016/317/b/e/cm_prism2_by_crist_jroger-daoa4en.jpg) (http://orig08.deviantart.net/d789/f/2016/317/9/9/cm_prism2_by_crist_jroger-daoa4en.jpg)


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 13, 2016, 01:06:15 AM
@darkbeam
I am not really sure but I thought  that Tglad fold was the same as Mbox at default setting and when the Mbox  limit:value ratio was at 1:2.  :hmh:  But when straying from this ratio (when using the MboxFold in an Mbox formula)  I think can cause nasty cuts therefore 99% of the time Tglads fold is the easiest one to use.

I thought, "ripristinate! is that a typo?" but it is a real word . :) Yeah, i assumed that was the correct way the transform should work, and had only added in the second rotation controls as a checkBox option.  Then I decided to delay figuring out if I could do a non-trig  back rotation. 


When I have time I may test adding this fold (from M3D somewhere?), to the UI :-

  z = fold2 - fabs( fabs(z + fold) - fold2) - fabs(fold)








Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 13, 2016, 02:12:46 AM
I  like these patterned surfaces that come out of mixing  all these IFS foldings as per attached image (there are still areas of  menger sponge inside as well.)  So now that I have Folding Tetra3D, Octo,  Menger and all this Cross Menger code, I can explore a lot more possibilities, and they are FAST to render. :)  (and there is Knighty's KIFS UI in Mandelbulber that can do much more if you learn how to use it.)


One of FRagmentariums advantages is in being able to have all these in a .frag for exploring , and when you find  a good place, just simply //comment out the transforms you have decided not to use. I currently  have a UI setup in this order : -

PrismShape
Rotation
CMT
CMkifs
Benesi T1
Benesi T1mod (a Tglad fold inside)
FabsMulti
Menger Sponge
 there is more rotations and other transforms to be added, but it already too big and clumsy .  :sad1:



Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 13, 2016, 02:27:27 AM
Attached image show what the Benesi t1Mod and the Fabs Multi transforms on the UI.  

Fabs Multi lets me explore various fabs() folds, but with the cost of the extra checkBoxes and maths.


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 13, 2016, 02:39:35 AM
@crist. Cool, checking out the dot modes. 

For prismShape2 I have added two more offset options. This allows me to replicate the variations I had between  earlier versions.

      t = max(0.0, dot1);
      if (fractal->transformCommon.functionEnabledBxFalse)
      {
         z.x -= t * -SQRT_3
                   - (fractal->transformCommon.offset0);
      }
      else
      {
         z.x -= t * -SQRT_3;
      }
      z.y = fabs(z.y - t);
      if (z.y > z.z)
      {
         temp = z.y;
         z.y = z.z;
         z.z = temp;
      }
      if (fractal->transformCommon.functionEnabledByFalse) z.y -= fractal->transformCommon.offset105;

      z -= gap * CVector3(SQRT_3_4, 1.5, 1.5);


Title: Re: Cross Menger!? Can anyone do this?
Post by: Crist-JRoger on November 13, 2016, 02:44:13 PM
mclarekin, i'm newbie in programming, more interested in fractal rendering ) So i really don't understand your code
This formula z = fold2 - fabs( fabs(z + fold) - fold2) - fabs(fold) What is fold and fold2?


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 14, 2016, 01:39:12 AM
@crist
These questions should be directed to Darkbeam. :police: ;D ;D ;D

But I will try to answer :)

This function contains two folds. Fold & fold2 are user defined variable parameters, usually a double or vect3.


This is the mapping or maths sequence where fold & fold2 can be pos or neg numbers

x' = fold2 - fabs( fabs(x + fold) - fold2) - fabs(fold)


broken into steps:


result' =  (x + fold);   shift x  by distance fold

result' = fabs(result);  fold the result, (fold the plane, all neg numbers are mapped over to positive)

result' = ( result - fold2); shift the result by distance fold2

result' = fabs(result);  again all negative numbers are folded to positive

x' = fold2 - result - fabs(fold);  final shifts.

fold is the number used to "shift / offset / translate / add_additionConstant" before doing the "absolute  function"

So I was thinking of trialling this in between a rotate_forward and a rotate_back. I think I already have included it as an amazing_surf fold option (it could be added to Tim Emit's amazing surf frag  set up.)


Title: Re: Cross Menger!? Can anyone do this?
Post by: Sabine on November 16, 2016, 11:36:26 AM
Please ignore, answered the wrong thread, my bad! :embarrass: Seems the topic was split while I was typing :}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on November 30, 2016, 12:22:49 PM
 I have just tried this Iteration Weight Transform with the prismShapeCMT, and it works well, ( as it does with menger sponge,, and   sometimes with other fractals, but I have  :hmh:forgotten).
The function occasionally can improve the DE quality
I generally put it as the last transform in a loop

// iteration weight transform.
// Influence fractal based on the weight of Z values at specified iterations
// intA & intB are positive int, (0,0,99)
// vec3 offsetIw1 & 2    slider (-5,0,5)
// float scaleIw     guessing slider (0,1,3)

if (iterW) {
   vec3 zA, zB;

   if (i == intA)
   {
      zA = z;
   }
   if (i == intB)
   {
      zB = z;
   }
   z = (z * scaleIw) + (zA * offsetIw1) + (zB * offsetIw2);
   Dd *= scaleIw;
   //aux.r_dz *= scaleIw;
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on December 21, 2016, 10:44:56 AM
I have been testing the DotModes in the PrismShape. There is some good things hidden in the combinations.  :)

Having the seperate bool  abs functions allows for more combinations (not all prismshape).  DE can get a bit bad with some.

These are the six DotModes I have tested .  My  loop was PrismShape, Octo, SphereFold, Rotation, Menger


Code:
	if(FabsXMode == 1)	z.x = fabs(z.x);

if(FabsYMode == 1) z.y = fabs(z.y);

if(FabsZMode == 1) z.z = fabs(z.z);


if(DotMode==0) {
float dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * scaleP;
float t = max(0.0, dot1);
z.x -= t * -SQRT_3;
z.y = fabs(z.y - t);
}
if(DotMode==1) {
float dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * scaleP;
float t = max(0.0, dot1);
z.y -= t * -SQRT_3;
z.x = fabs(z.x - t); // x y swap
}

if(DotMode==2) {
float dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * scaleP;
float t = max(0.0, dot1);
z.z -= t * -SQRT_3;
z.y = fabs(z.y - t);  // z.z z.y swap
}
if(DotMode==3) {
float dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * scaleP;
float t = max(0.0, dot1);
z.y -= t * -SQRT_3;
z.z = fabs(z.z - t);  // z.z z.y swap
}

if(DotMode==4) {
float dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * scaleP;
float t = max(0.0, dot1);
z.zy -= t * -SQRT_3;
z.xy = fabs(z.yx - t);  //x y swap and other things
}

if(DotMode==5) {
float dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * scaleP;
float t = max(0.0, dot1);
z.xy -= t * -SQRT_3;
z.yz = fabs(z.yz - t);  //x y swap and other things
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: mclarekin on January 07, 2017, 09:33:51 AM
Finally finished PrismShape2.  Attached hybrid image is CMT (3 iters) Mbox (the rest)

Code:
/**
 * Menger Prism Shape2
 * from code by Knighty
 * http://www.fractalforums.com/fragmentarium/
 * cross-menger!-can-anyone-do-this/msg93972/#new
 */
void MengerPrismShape2Iteration(CVector3 &z, int i, const cFractal *fractal, sExtendedAux &aux)
{
CVector3 gap = fractal->transformCommon.constantMultiplier000;
double t;
double dot1;
if (fractal->transformCommon.functionEnabledSwFalse)
{
z = CVector3{-z.z, z.x, z.y};
}
if (fractal->transformCommon.functionEnabledx && i >= fractal->transformCommon.startIterationsP
&& i < fractal->transformCommon.stopIterationsP1)
{
if (fractal->transformCommon.functionEnabledCxFalse)
{
z.x = fabs(z.x);
}
if (fractal->transformCommon.functionEnabledCy)
{
z.y = fabs(z.y);
}
if (fractal->transformCommon.functionEnabledCz)
{
z.z = fabs(z.z);
}
double tempOff = (fractal->transformCommon.offset0 + SQRT_3_4d2);
switch (fractal->combo.modeA)
{
case sFractalCombo::mode0:
default:
dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.x -= t * -SQRT_3 - tempOff;
z.y = fabs(z.y - t);
break;
case sFractalCombo::mode1:
dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.y -= t * -SQRT_3 - tempOff;
z.x = fabs(z.x - t); // x y swap
break;
case sFractalCombo::mode2:
dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.z -= t * -SQRT_3 - tempOff;
z.y = fabs(z.y - t); // z y swap
break;
case sFractalCombo::mode3:
dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.y -= t * -SQRT_3 - tempOff;
z.z = fabs(z.z - t); // z y swap
break;
case sFractalCombo::mode4:
dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.y -= t * -SQRT_3 - tempOff;
z.z -= t * -SQRT_3 - tempOff;
z.x = fabs(z.x - t); // x y swap and other things
z.y = fabs(z.y - t);
break;
case sFractalCombo::mode5:
dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.x -= t * -SQRT_3 - tempOff;
z.y -= t * -SQRT_3 - tempOff;
z.y = fabs(z.y - t); // x y swap and other things
z.z = fabs(z.z - t);
break;
case sFractalCombo::mode6:
dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.y -= t * -SQRT_3 - (fractal->transformCommon.offset0);
z.z -= t * -SQRT_3 - (fractal->transformCommon.offset0);
z.x = fabs(z.y - t); // x y swap and other things and swizzle
z.y = fabs(z.x - t);
break;
case sFractalCombo::mode7:
dot1 = (z.z * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scale;
t = max(0.0, dot1);
z.x -= t * -SQRT_3 - (fractal->transformCommon.offset0);
z.y -= t * -SQRT_3 - (fractal->transformCommon.offset0);
z.y = fabs(z.z - t); // x y swap and other things and swizzle
z.z = fabs(z.y - t);
break;
}

if (z.y > z.z) swap(z.y, z.z);
z.y -= fractal->transformCommon.offsetB0;

z -= gap * CVector3(SQRT_3_4, 1.5, 1.5);

if (z.z > z.x) swap(z.z, z.x);

if (fractal->transformCommon.functionEnabledyFalse)
{
z.y = max(0.0, z.y) * fractal->transformCommon.scaleA1;
z.z = max(0.0, z.z) * fractal->transformCommon.scaleB1;
}
if (fractal->transformCommon.functionEnabledzFalse)
{
if (z.x >= 0.0)
{
z.y = max(0.0, z.y) * fractal->transformCommon.scaleA1;
z.z = max(0.0, z.z) * fractal->transformCommon.scaleB1;
}
}
z *= fractal->transformCommon.scale1;
aux.DE *= fractal->transformCommon.scale1;
aux.DE *= fractal->transformCommon.scaleC1;
}

if (fractal->transformCommon.functionEnabledXFalse
&& i >= fractal->transformCommon.startIterationsA
&& i < fractal->transformCommon.stopIterationsA)
{ // CrossMengerTrick
double dd = aux.DE;
z.y = fabs(z.y);
z.z = fabs(z.z);
if (fractal->transformCommon.functionEnabledCyFalse)
{
z.x = fabs(z.x);
}
dot1 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scaleD1;
double t = max(0.0, dot1);
z.x -= t * -SQRT_3;
if (fractal->transformCommon.functionEnabledBzFalse)
{
z.y = fabs(z.y) - t;
}
else
{
z.y = fabs(z.y - t);
}
z.x -= SQRT_3_4;
double dy = 0.0;
double dz = 0.0;
if (z.y > 0.5 && z.z > 0.5)
{
dy = 1.5;
dz = 1.5;
}
else if ((z.y - 1.5) * (z.y - 1.5) + z.z * z.z < z.y * z.y + (z.z - 1.5) * (z.z - 1.5))
{
dy = 1.5;
}
else
dz = 1.5;

z.y -= dy;
z.z -= dz;
z *= fractal->transformCommon.scaleA3;
aux.DE *= fractal->transformCommon.scaleA3;
z.y += dy;
z.z += dz;
z.x += SQRT_3_4;

if (fractal->transformCommon.functionEnabledFalse)
{
dd *= 0.33333333333333333333333333333 * fractal->transformCommon.scaleE1;
z *= dd;
aux.DE *= dd;
}
aux.DE *= fractal->transformCommon.offset1; //.DE tweak cross menger trick part
}
if (fractal->transformCommon.functionEnabledPFalse)
{
z.x = fabs(z.x + fractal->transformCommon.offset) + fractal->transformCommon.offsetC0;
}

// void KIFS(vec3 z)
//{//Pure KIFS... almost correct

if (fractal->transformCommon.functionEnabledKFalse
&& i >= fractal->transformCommon.startIterationsB
&& i < fractal->transformCommon.stopIterationsB)
{
if (fractal->transformCommon.functionEnabledCzFalse)
{
z.x = fabs(fractal->transformCommon.offset - z.x ) + fractal->transformCommon.offsetC0;
}

z.y = fabs(z.y);
z.z = fabs(z.z);

double dot2 = (z.x * -SQRT_3_4 + z.y * 0.5) * fractal->transformCommon.scaleF1;
double t = max(0.0, dot2);

z.x -= t * -SQRT_3;
z.y = fabs(z.y - t);

if (z.y > z.z) swap(z.y, z.z);

z.y = fabs(z.y - 0.5) + 0.5;

z -= CVector3(0.5 * SQRT_3, 1.5, 1.5);

z *= fractal->transformCommon.scaleB3;
aux.DE *= fractal->transformCommon.scaleB3;


z += CVector3(0.5 * SQRT_3, 1.5, 1.5);
}


Title: Re: Cross Menger!? Can anyone do this?
Post by: Sabine on January 07, 2017, 07:40:12 PM
Congratulations, mclarekin!  :beer: :beer: :beer:





Title: Re: Cross Menger!? Can anyone do this?
Post by: Tim Emit on January 09, 2017, 07:41:44 PM
excellent  :)


Title: Re: Cross Menger!? Can anyone do this?
Post by: Patryk Kizny on March 27, 2017, 11:54:08 AM
I remember either in Mandelbulb or Mandelbulber there's an IFS mode that actaully allows you to introduce many planes of symmetry and even rotate them per iteration. Perhaps that would be a generalization of what you did here and could be brought here to tweak the code further?