Welcome to Fractal Forums

Fractal Software => 3D Fractal Generation => Topic started by: knighty on April 07, 2010, 09:41:45 PM




Title: "Smooth" folding
Post by: knighty on April 07, 2010, 09:41:45 PM
Melting scale 3.0 mandelbox raytraced using Buddhi's DE.
(http://www.fractalforums.com/gallery/2/932_05_04_10_10_36_43.jpeg)

This is my attempt at "smoothing" the foldings of the original mandelbox. I've replaced the cube folding by:

   y = sqrt( a + ( x + 1 )^2 ) - sqrt( a + ( x - 1 )^2 ) - x.                           (thanks Timeroot  :))
   I used a=0.1

And the "sphere" folding by:
   r = sqrt( x^2 + y^2 + z^2 )
   k = 3 * r - 2 ;
   new_r = 1 / 3 * ( k^3 - k + 6 ) / ( k^2 + 1 )
   x *= new_r / r
   y *= new_r / r
   z *= new_r / r

   (DEfactor*=new_r / r; for the distance Estimation)

it's very slow. Moreover, a good distance estimator (taking into account the smoothing) is to be found.

What do you think of it?  :embarrass:


Title: Re: "Smooth" folding
Post by: reesej2 on April 09, 2010, 08:44:49 AM
Oh, very interesting. It looks like the Mandelbox, but with all the edges rounded. What happens if you vary the value of a?


Title: Re: "Smooth" folding
Post by: knighty on April 10, 2010, 12:45:53 AM
Yes! this is because of the smoothness of the "foldings". It looks like if it was made out of clay ^-^. Unfortunately, the details are also washed out. I don't know if it's due to the distance estimation method I'm using.

Here are renderings for different parameters of a and smooth sphere "folding" (scale=3):
a=0.0
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF0_SSphF.jpg)

a=0.1
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF1_SSphF.jpg)

a=0.2
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF2_SSphF.jpg)

a=0.3
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF3_SSphF.jpg)

Things get less interresting for bigger a.

Here are renderings for different parameters of a and the original sphere folding (scale=2):

a=0.1
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF1.jpg)

a=0.2
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF2.jpg)

a=0.3
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF3.jpg)

a=0.4
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF4.jpg)

a=0.5
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF5.jpg)

a=0.5 and a small solid threshold (I have a bug with my shadow rendering code so I've disabled it)
(http://i395.photobucket.com/albums/pp36/jnosof/Melting%20Mandelbox/MBox_SBoxF5_small_solid_threshold.jpg)


Title: Re: "Smooth" folding
Post by: reesej2 on April 10, 2010, 08:44:42 AM
Hmm... it does seem like larger a-values produce blockier results. 0 looks like it's very close to the original box... what about negative a-values? Will that work?


Title: Re: "Smooth" folding
Post by: knighty on April 10, 2010, 06:07:15 PM
the function:

f(x) = sqrt( a + ( x + 1 )^2 ) - sqrt( a + ( x - 1 )^2 ) - x.

gives exactly the same result as:

if(x>1.0) x=2.0-x; else if(x<-1.0) x=-2.0-x;

Using negative a doesn't work because for some x you will get a+(x+-1)^2<0.


Title: Re: "Smooth" folding
Post by: reesej2 on April 11, 2010, 07:54:06 AM
Oh, yes, that makes sense. Also, I think you mean it gives exactly the same result when a = 0. Hm... it doesn't produce the exact same Mandelbox though. That would be because of the smooth sphere folding. I'd be interested to see what happens as that formula is varied, but I'm not sure if there's a convenient parameter in that.


Title: Re: "Smooth" folding
Post by: Timeroot on April 11, 2010, 08:15:07 PM
That's interesting, the way it turned out. The sphere folding could also be done with some like hyperbolas... you can make a smooth approximation of any piecewise function with them. It would end up being really computationally expensive, though. With the current formula, I've been playing around with what happens as I change the powers to something like 1 / 3 * ( k^11 - k^3+ 6 ) / ( k^10 + 1 ), with interesting results. It makes it "sharper", so it could be used as a smoothness parameter, but it completely loses the area where it acts like 1/x. It's like setting minRadius to 1.


Title: Re: "Smooth" folding
Post by: knighty on April 11, 2010, 08:57:38 PM
Quote
I think you mean it gives exactly the same result when a = 0
Yes. Sorry, i've forgetten to mention it.

Quote
it doesn't produce the exact same Mandelbox though. That would be because of the smooth sphere folding. I'd be interested to see what happens as that formula is varied, but I'm not sure if there's a convenient parameter in that.
Indeed, It's the effect of smooth sphere folding. I'm still looking for a function which limit is the original sphere folding. Any idea...?

Quote
The sphere folding could also be done with some like hyperbolas... you can make a smooth approximation of any piecewise function with them. It would end up being really computationally expensive, though. With the current formula, I've been playing around with what happens as I change the powers to something like 1 / 3 * ( k^11 - k^3+ 6 ) / ( k^10 + 1 ), with interesting results. It makes it "sharper", so it could be used as a smoothness parameter, but it completely loses the area where it acts like 1/x. It's like setting minRadius to 1.
... These are two ideas... thanks... again. ;)


Title: Re: "Smooth" folding
Post by: eiffie on May 24, 2011, 05:17:59 PM
Just thought I'd add a fast smoothing method in glsl is to use the function smoothstep on the spherical folding.


Title: Re: "Smooth" folding
Post by: DarkBeam on July 25, 2011, 11:44:11 AM
Well well! I think smooth folding expression is very complex and it can be reduced a bit ;)
Why not mess around with this
a=sgn(x)
x=abs(x)
x=a*(x/(1+x*x*x*x)+(2fold-x)*x*x/(1+x*x))
It is zero if x is zero and tends to the exact value if x is big. :)
Needs some refinement for sure but somebody can do a test render plz? :D


Title: Re: "Smooth" folding
Post by: DarkBeam on August 09, 2011, 10:59:43 AM
Okay now the smooth ABox is for MB3D too. My formula is simplified and different from knighty's, and for now I didn't modified the sphere fold, ;) enjoy if u can :D


Title: Re: "Smooth" folding
Post by: knighty on August 26, 2011, 01:33:01 AM
Hi,
DarkBeam: How are you computing the running derivative? I'm curious because I couldn't get a good distance estimate. Also, have you tried Buddhi's method? It looks better than mine.


Title: Re: "Smooth" folding
Post by: DarkBeam on September 13, 2011, 11:49:42 PM
Well, the current formula is far more complex than that. I even don't remember it 'cause it is long, so look at my formula archive! :D It has the raw code and the transcription in pseudo c...
Have lots of fun ;)


Title: Re: "Smooth" folding
Post by: DarkBeam on September 18, 2011, 12:23:53 PM
Here I paste the description from my formula! ;)

Quote
An Amazing Box, with Folding function modified as follows (x is each spatial coord);

 xp = fix1*x**p; (fast int pow, p is forced to be > 2)
 u=sgn(x)*xp;
 x=x+xp*(2*Fold-x);
 x=x/u;

Also radius folding is smooth (when r<0.99);

 r = (x*x+y*y+z*z);
 if r>0.99
 r=1; // prevents fp troubles and speeds up a lot in this case
 else
 m=(1+minr)/2; n=(1-minr)/2; r1=(r-m)/n; rs=sgn(r1); r1=abs(r1);
 rsqrt = sqrt(r1); // this slows down the convergence
 rp=fix2*(rsqrt**p); (fast int pow, p is forced to be > 3)
 r = rs*((rp+r1)/(rp+1) * n) + m;
 endif

 (then r = scale / r and is used as a multiplier for x,y,z)