Hi! I have a little question for you.
Can you set distortion completely repeated picture of texture? I mean the full march of relief and coloring.
Thank you!
The patterns don't match up perfectly inside the fractal (just on certain faces!)... I think it's because the Menger switches orientation as the calculation proceeds. On second thought.. maybe need to use the same orbitTraps for both. Will UPDATE later...
UPDATE: Forgot to post it! I didn't figure out the orientation problem yet. I'll post the Menger and raytracer here, but the coloring only aligns perfectly in certain cases.
With the Menger, I'm assuming that interior orientations are switched around as the x,y, and z coordinates are selected from, since the z coordinate is the one the majority of operations are performed on (although I should probably look at the math of this version before I go making statements like that.... will later).
I wrote another version of the Menger sponge a LONG time ago that didn't use the orientation optimizations that Knighty, Kali or maybe msltoe?? (I forgot who did it, I apologize!) introduced. It calculated EVERY single part of the whole cube individually, which means that it preserves orientations.
Hahaha... whoever thought that my old clunky non-optimized formula would be useful? I'll dig around.
For your amusement:
rmin=minRadius;
r=sqr(sx- 1) + sqr(sy- 1) + sqr (sz- 1 );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=1 ; sz2=1 ;
}
r=sqr(sx) + sqr(sy- 1) + sqr (sz- 1);
if (r<rmin) {
rmin=r; sx2=0 ; sy2=1 ; sz2=1 ;
}
r=sqr(sx+1) + sqr(sy- 1) + sqr (sz- 1 );
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=1 ; sz2=1 ; /* third one */
}
r=sqr(sx- 1) + sqr(sy) + sqr (sz- 1 );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=0 ; sz2=1 ;
}
r=sqr(sx+1) + sqr(sy) + sqr (sz- 1 );
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=0 ; sz2=1 ;
}
r=sqr(sx- 1) + sqr(sy+1) + sqr (sz- 1 );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=-1 ; sz2=1 ;
}
r=sqr(sx) + sqr(sy+1) + sqr (sz- 1);
if (r<rmin) {
rmin=r; sx2=0 ; sy2=-1 ; sz2=1 ;
}
r=sqr(sx+1) + sqr(sy+1) + sqr (sz- 1 ); /* 9 */
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=-1 ; sz2=1 ;
}
/* next set */
r=sqr(sx+ 1) + sqr(sy- 1) + sqr (sz );
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=1 ; sz2=0 ;
}
r=sqr(sx+1) + sqr(sy+ 1) + sqr (sz );
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=-1 ; sz2=0 ; /* third one */
}
r=sqr(sx- 1) + sqr(sy+1) + sqr (sz );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=-1 ; sz2=0 ;
}
r=sqr(sx-1) + sqr(sy-1) + sqr (sz ); /* 6 */
if (r<rmin) {
rmin=r; sx2=1 ; sy2=1 ; sz2=0 ;
}
/* -z set */
r=sqr(sx- 1) + sqr(sy- 1) + sqr (sz+ 1 );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=1 ; sz2=-1 ;
}
r=sqr(sx) + sqr(sy- 1) + sqr (sz+ 1);
if (r<rmin) {
rmin=r; sx2=0 ; sy2=1 ; sz2=-1 ;
}
r=sqr(sx+1) + sqr(sy- 1) + sqr (sz+ 1 );
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=1 ; sz2=-1 ; /* third one */
}
r=sqr(sx- 1) + sqr(sy) + sqr (sz+ 1 );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=0 ; sz2=-1 ;
}
r=sqr(sx+1) + sqr(sy) + sqr (sz+ 1 );
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=0 ; sz2=-1 ;
}
r=sqr(sx- 1) + sqr(sy+1) + sqr (sz+ 1 );
if (r<rmin) {
rmin=r; sx2=1 ; sy2=-1 ; sz2=-1 ;
}
r=sqr(sx) + sqr(sy+1) + sqr (sz+1);
if (r<rmin) {
rmin=r; sx2=0 ; sy2=-1 ; sz2=-1 ;
}
r=sqr(sx+1) + sqr(sy+1) + sqr (sz+ 1 ); /* 9 */
if (r<rmin) {
rmin=r; sx2=-1 ; sy2=-1 ; sz2=-1 ;
}
if (juliaMode) {
sx= cr+ scalef*sx-sx2*scalef2;
sy= ci+ scalef*sy-sy2*scalef2;
sz= cj+ scalef*sz-sz2*scalef2;
} else {
sx= pixelr+ scalef*sx-sx2*scalef2;
sy= pixeli+ scalef*sy-sy2*scalef2;
sz= pixelj+ scalef*sz-sz2*scalef2;
}
z=quaternion(sx,sy,sz,sqrt(sqr(sx)+sqr(sy)+sqr(sz)));
//bailout = sqrt(scalef2);
if (skmode) {
if (abs(sx)>abs(sy) && abs(sx)>abs(sz)) {
bail=abs(sx);
} else if (abs(sy)>abs(sz)) {
bail= abs(sy);
} else {
bail=abs(sz);
} } else {
bail = sqr(sx)+sqr(sy)+sqr(sz);
}
So... it'll take a bit of editing and rewriting. Actually, I think there might be some other old Menger code around here that doesn't use the abs(z) optimization.. but maybe not. I didn't see it when I did a search.
Anyway- the point is that for the Menger, I need to rewrite the whole thing in order to see if preserving orientation helps. We'll see...
A couple things (about the updated version... which isn't attached now because I have a few things to fix):
1) orbits are trapped on the coloring iteration for texture based coloring, so you'll have to capture color orbits on the same iteration as you're doing the height map (use trapmode switch in the Menger tab, and set coloring iterations to 0 to try it out in the following frags)
2) I re-wrote the raytracer and Menger so that the maptypes are the same, HOWEVER, it won't allow you to load the same texture twice (maybe some "streamlining" in the compiler) unless you rename the 2nd texture as another name...
You can click the "trapmode" option in the Menger tab, set color iterations to 0, heightIter=1, and match your texture and heightmap settings if you want to try to align coloring with the heightmap in the code I am attaching (including fast-raytracer.frag).
Turn off trapmode, and set coloring iterations= 1 less than height iterations if you want to match them up in different ways.
For some reason mapmode 0 doesn't match when color iterations !=0, trapmode is not set, and heightIter=coloriterations+1, but mapmode1 does.... so... :shrug: