Logo by haltenny - Contribute your own Logo!

END OF AN ERA, FRACTALFORUMS.COM IS CONTINUED ON FRACTALFORUMS.ORG

it was a great time but no longer maintainable by c.Kleinhuis contact him for any data retrieval,
thanks and see you perhaps in 10 years again

this forum will stay online for reference
News: Support us via Flattr FLATTR Link
 
*
Welcome, Guest. Please login or register. April 27, 2024, 12:33:25 AM


Login with username, password and session length


The All New FractalForums is now in Public Beta Testing! Visit FractalForums.org and check it out!


Pages: [1] 2   Go Down
  Print  
Share this topic on DiggShare this topic on FacebookShare this topic on GoogleShare this topic on RedditShare this topic on StumbleUponShare this topic on Twitter
Author Topic: Mandelbox distance estimation problem  (Read 19621 times)
Description: Problem for scales in [-2,-1]
0 Members and 1 Guest are viewing this topic.
barkeg
Alien
***
Posts: 29



« on: July 28, 2011, 02:24:54 PM »

I had posted that before...but I think it is an other problem so I created a new topic and deleted the message before:

I've tested Buddhi's distance estimate formula. Works very fine!



But I have a problem with scales between [-2 , -1]

it seems very rounded, seems to be some kind of "spherical clipping"

scale=-1.7:


scale=-1.6:



Does anyone know why this happens? Or is it because of the distance estimation formula?
....I loved the scale=-1.5 so much but now it is just nearly a sphere!!! wink


First I thought it was near plane clipping but it isn´t because it´s far away.

Here is an animation: scale=-1.7



When I move the near plane to far away the fractal disapears completly, the same when moving the plane to near.
The first thing shouldn't happen because I use orthographic projection to test this.

The rotations and near plane should be ok because I tested the same code on a voxel system and it wend fine (and it happens only for scales between [-2,-1])

here is the code from Buddhi:

Quote
inside iteration loop:

DEfactor = scale;

fixedRadius = 1.0;
fR2 = fixedRadius * fixedRadius;
minRadius = 0.5;
mR2 = minRadius * minRadius;

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

r2 = x*x + y*y + z*z;

if (r2 < mR2)
{
   x = x * fR2 / mR2;
   y = y * fR2 / mR2;
   z = z * fR2 / mR2;
   DEfactor = DEfactor * fR2 / mR2;
}
else if (r2 < fR2)
{
   x = x * fR2 / r2;
   y = y * fR2 / r2;
   z = z * fR2 / r2;
   DEfactor *= fR2 / r2;
}

x = x * scale + cx;
y = y * scale + cy;
z = z * scale + cz;
DEfactor *= scale;

resultant estimated distance (after iteration loop):

distance = sqrt(x*x+y*y+z*z)/abs(DEfactor);

I guess that DEfactor = scale; is outside the iteration loop.

« Last Edit: July 28, 2011, 02:26:35 PM by barkeg » Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #1 on: July 29, 2011, 01:02:08 AM »

Increase the bailout value ?
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
marius
Fractal Lover
**
Posts: 206


« Reply #2 on: July 29, 2011, 01:49:30 AM »

I had posted that before...but I think it is an other problem so I created a new topic and deleted the message before:

I've tested Buddhi's distance estimate formula. Works very fine!

..

But I have a problem with scales between [-2 , -1]

it seems very rounded, seems to be some kind of "spherical clipping"

Does anyone know why this happens? Or is it because of the distance estimation formula?
....I loved the scale=-1.5 so much but now it is just nearly a sphere!!! wink


First I thought it was near plane clipping but it isn´t because it´s far away.

When I move the near plane to far away the fractal disapears completly, the same when moving the plane to near.
The first thing shouldn't happen because I use orthographic projection to test this.

The rotations and near plane should be ok because I tested the same code on a voxel system and it wend fine (and it happens only for scales between [-2,-1])

here is the code from Buddhi:

Quote
inside iteration loop:

DEfactor = scale;

fixedRadius = 1.0;
fR2 = fixedRadius * fixedRadius;
minRadius = 0.5;
mR2 = minRadius * minRadius;

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

r2 = x*x + y*y + z*z;

if (r2 < mR2)
{
   x = x * fR2 / mR2;
   y = y * fR2 / mR2;
   z = z * fR2 / mR2;
   DEfactor = DEfactor * fR2 / mR2;
}
else if (r2 < fR2)
{
   x = x * fR2 / r2;
   y = y * fR2 / r2;
   z = z * fR2 / r2;
   DEfactor *= fR2 / r2;
}

x = x * scale + cx;
y = y * scale + cy;
z = z * scale + cz;
DEfactor *= scale;

resultant estimated distance (after iteration loop):

distance = sqrt(x*x+y*y+z*z)/abs(DEfactor);

I guess that DEfactor = scale; is outside the iteration loop.



initialize DEfactor = 1.0, not scale?
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #3 on: July 29, 2011, 02:29:29 AM »

Apologies - I missed the video which shows it's obviously not uniform but based on viewpoint location, I'd guess marius is correct ?
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
barkeg
Alien
***
Posts: 29



« Reply #4 on: July 29, 2011, 12:54:13 PM »

Quote
Increase the bailout value ?

I tested that before but it stays the same.

Quote
initialize DEfactor = 1.0, not scale?

It only renders a black screen.

I thought it could be because the estimated distance is to big, so I multiplied the estimated distance by a factor<1 (>0):

distance = 0.5*sqrt(x*x+y*y+z*z)/abs(DEfactor);

0.5 worked fine for me for scale=-1.5
But for scales closer to -1 I had to decrease the factor

Alternatively I could initialize DEfactor=2.0*scale

Thanks for the idea!







« Last Edit: July 29, 2011, 01:01:20 PM by barkeg » Logged
barkeg
Alien
***
Posts: 29



« Reply #5 on: August 06, 2011, 08:25:38 PM »

Another question:

Is there anything like  a distance estimation formula for hybrid fractals (for a mandelbox with rotation)?
Logged
eiffie
Guest
« Reply #6 on: August 09, 2011, 05:49:53 PM »

I don't change the DE at all when using rotations like:
z=z*RotationMatrix; //the length of z isn't changing

If you are creating a hybrid of two fractal formulas typically you can multiply the "DEFactors".
« Last Edit: August 09, 2011, 05:52:57 PM by eiffie » Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #7 on: August 09, 2011, 08:27:04 PM »

Whatever formula combinations you use each should simply take the current DE value and apply it's own modification i.e. every formula applied in a hybrid needs to also apply it's own (correct) modification to the running DE value.
Of course if using the brute-force smooth iteration method (Buddhi's delta DE) then no running DE is needed and the more complex the overall iteration becomes then the more optimum using the delta DE becomes basically because errors in the combined analytical DE are cumulative in the worst places whereas the accuracy of the delta DE is more independent of the overall complexity (assuming of course that an accurate smooth iteration value is possible for the overall formula) and the calculations involved in delta DE are essentially independent of the complexity whereas analytical DE gets slower as more formulas are added to a hybrid.
In either case (analytical or delta) the worst errors occur in fractals that have areas with discontinuities in the smooth iteration value e.g. a space of 5 iterations touching a space of 7 with no space of 6 in between - typically this is formulas with conditionals or fractional powers.
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
barkeg
Alien
***
Posts: 29



« Reply #8 on: August 11, 2011, 08:03:46 PM »

Thank you for your reply. I appreciate that!

-So I can use the the DEfactor or the distance after the mandelbox part to apply it's own modification of a mandelbulb. The thing is I don't know how since there were trigonometric functions. I found a method for the mandelbulb on the web of Iñigo Quilez that could be implemented by using the derivative which can be calculated in the iteration loop. But that gives me finally a distance and I can't apply this to the DEfactor or distance calculated before in the mandelbox part.

-Where can I find your Delta DE method? I looked here in the forum and you mention it a lot but I couldn't find it (or I didn't recognise it). It would be nice if you could send me a link or something because I get really lost when you talk about smooth iteration value  embarrass

-
Quote
a space of 5 iterations touching a space of 7 with no space of 6 in between
I don't understand that at all. I'm using the same number of iterations for the entire fractal to calculate the DE

Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #9 on: August 11, 2011, 10:08:45 PM »

Thank you for your reply. I appreciate that!

-So I can use the the DEfactor or the distance after the mandelbox part to apply it's own modification of a mandelbulb. The thing is I don't know how since there were trigonometric functions. I found a method for the mandelbulb on the web of Iñigo Quilez that could be implemented by using the derivative which can be calculated in the iteration loop. But that gives me finally a distance and I can't apply this to the DEfactor or distance calculated before in the mandelbox part.

-Where can I find your Delta DE method? I looked here in the forum and you mention it a lot but I couldn't find it (or I didn't recognise it). It would be nice if you could send me a link or something because I get really lost when you talk about smooth iteration value  embarrass

-
Quote
a space of 5 iterations touching a space of 7 with no space of 6 in between
I don't understand that at all. I'm using the same number of iterations for the entire fractal to calculate the DE

You don't need to worry about the trig too much, in the case of polynomials (even using the odd Mandelbulb triplex maths) it turns out that the running DE is exactly the same as that for plain complex or quaternions etc.

i.e. If your current running DE value is d and you're applying z^p+c on a given iteration then the new running DE value is

 d = p*d*z^(p-1)

(That may need a +1 on the end for either Mandy's or Julias I forget which)
Of course the z^(p-1) needs to be calculated using the correct number form i.e. using triplex math for the Mandelbulb matching the triplex math used for z^p+c.

This is "off the top of my head" and it's a while since I messed with it and my memory isn't what it was but...
My delta DE is simply done by calculating the smooth iteration value for the current point on the ray, for a point deltax up the x axis, a point deltay (magnitude same as deltax) up the y axis and a point deltaz (same magnitude) up the z axis - the delta being a suitably small value according to the current required distance threshold for "solid".
Of course this is an overhead of 3 full iteration loops per step along the ray compared to using analytical DE *but* of course the analytical DE calculation involves calculations done on every iteration whereas the smooth iteration value only involves calculation on bailout.
You then take the differences in the smooth iteration value i.e. (value for point offset in x - value for base point (at step on ray), value for point offset in y - value for base point, value for point offset in z - value for base point) and get the magnitude of this (as a 3D vector) and then adjust appropriately to give a DE value.
Buddhi's method I think is similar except if I remember correctly he iterates at the delta offsets always to the same iteration count as the base point (at current step on the ray)  and uses the bailout values rather than the smooth iteration values.

With respect to the iteration count - I was talking about points along the ray before you reach solid - here the ray will pass through space of different iteration levels at bailout and for many fractals (like the Mandelbulb) although the shape of the boundaries from one iteration depth to the next are fractal and irregular they are always consistent i.e. there will never be a point of 5 iterations at bailout directly next (I mean in the infinitessimal limit) to a point of 7 iterations at bailout - there's always a point between of 6 iterations at bailout.
To a certain degree even analytical DE relies on this but some fractals, notably some fractals with conditionals in the formula and fractals with fractional powers, have adjacent points where the iteration count at bailout is discontinuous and such formulas always present rendering issues due to "incorrect" calculation of the distance estimate.
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
barkeg
Alien
***
Posts: 29



« Reply #10 on: August 11, 2011, 11:59:15 PM »

Thanks, David! That helps me a lot!

I found a pseudo code you posted on here some time ago and that helps me too!

Just one thing I don't know:

Quote
smooth = final iter + 1 + (log(log(bailout))-log(log(final magnitude)))/log(power)

Or (for much more accurate results) instead of log(power) use log(log(|z|)/log(|zold|)) when final iter is >1 (where zold is the penultimate value of z i.e. z from the iteration prior to bailout).
from http://www.fractalforums.com/theory/a-new-simple-way-to-compute-de-for-any-trig-mandelbulb/

-What is "final iter"? Number of iterations?

(I think it's indifferent to which base the log is because it's the same as "log_power(log_final magnitude(bailout))" where Log_"anything"= log to base "anything")

I assume that "final magnitude" is |z| after the iteration loop.

Physically, what is the soomth iteration value (concept)? I mean, I know how to calculate it but how did you come up with it?
Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #11 on: August 12, 2011, 03:43:13 AM »

Thanks, David! That helps me a lot!

I found a pseudo code you posted on here some time ago and that helps me too!

Just one thing I don't know:

Quote
smooth = final iter + 1 + (log(log(bailout))-log(log(final magnitude)))/log(power)

Or (for much more accurate results) instead of log(power) use log(log(|z|)/log(|zold|)) when final iter is >1 (where zold is the penultimate value of z i.e. z from the iteration prior to bailout).
from http://www.fractalforums.com/theory/a-new-simple-way-to-compute-de-for-any-trig-mandelbulb/

-What is "final iter"? Number of iterations?

(I think it's indifferent to which base the log is because it's the same as "log_power(log_final magnitude(bailout))" where Log_"anything"= log to base "anything")

I assume that "final magnitude" is |z| after the iteration loop.

Physically, what is the soomth iteration value (concept)? I mean, I know how to calculate it but how did you come up with it?

Final iter is indeed the iteration count at bailout and in log(log(|z|)/log(|zold|)) |z| can be either the final magnitude or its square as long as |zold| matches as either the penultimate magnitude or its square.
Obviously if avoiding the square root in the bailout testing (e.g. in a shader using dot(z,z) instead of length(z)) i.e. testing against the square of the bailout then you have to ensure you use the correct values in  (log(log(bailout))-log(log(final magnitude))).
i.e. again either both the non-squared or the squared, obviously it's simplest to match which you use in the bailout test.


The original smooth iteration this is based on was outlined (I believe) by Linas Vepstas and an online search should find info on that.
The key to it being successful as a deltaDE method is ensuring that it remains as smooth as possible everywhere even for more esoteric formulas i.e. such that no hard-breaks are introduced at iteration boundaries and the technique of using the actual divergence at bailout i.e. log(log(|z|)/log(|zold|)) was my idea - it came suddenly to me when trying to sleep after thinking about possible ways of getting correct smoothing everywhere on the standard complex "lambda" fractal - I suddenly realised that the reason for variation across the fractal in that case was due to varying divergence at bailout based on position (because of "c" being a scaling factor in that case) and the idea of using the actual divergence on bailout was a sudden inspiration and I went to sleep happy convinced it would work on the lambda mandy which it did, the surprise was that it also worked in many other cases where smooth iteration colouring was problematic - even exp(z)+c or sin(z)+c and vastly improving the Barnsely's - though for the Barnsley's Ron Barnett's cumulative exp smoothing is better though it doesn't quite follow the contours of plain banded iteration.
Of course for delta DE you can avoid the final iteration value altogether and just work with the rest of the values provided that you iterate at all 4 points to the same iteration count (i.e. whatever iteration count the base point on the ray bails out at, then perform that number of iterations at each of the "delta" offset points).
Also in some formulas using the plain magnitude differences for deltaDE as Buddhi outlined somewhere works better but for other formulas the smooth iteration differences work better.
Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
barkeg
Alien
***
Posts: 29



« Reply #12 on: August 12, 2011, 12:46:26 PM »

Thanks a lot!

I think I understand it now. This seems to be a lot more easier to apply because I don't have to calculate the jacobian grin

Quote
If your current running DE value is d and you're applying z^p+c on a given iteration then the new running DE value is

 d = p*d*z^(p-1)

(That may need a +1 on the end for either Mandy's or Julias I forget which)
Of course the z^(p-1) needs to be calculated using the correct number form i.e. using triplex math for the Mandelbulb matching the triplex math used for z^p+c.

So z^(p-1) is a triplex number and multiplied by tow scalars it still keeps triplex .... but 'd' should be a scalar
I don't understand that or am I getting something wrong?

(by the way I think the Mandy's are those which  need a +1 on the x axis)

-Final iter is the iteration count at bailout at the current point in space. The same as in a voxel system when testing each voxel (until |z|>bailout) right? So it never should happen that final iter reaches max. iteration (or maybe sometimes because of overstepping)?
« Last Edit: August 12, 2011, 12:52:29 PM by barkeg » Logged
David Makin
Global Moderator
Fractal Senior
******
Posts: 2286



Makin' Magic Fractals
WWW
« Reply #13 on: August 12, 2011, 11:04:35 PM »

Apologies, I forgot that Jos Leys showed that you could just use the magnitude rather than the full triplex - here's some code directly from my UF formula:
                if @useDE==0 ;(i.e. type 0)
                  dr = @mpwr*dr*magn^(@mpwr-1.0)
                  if @fractaltype==1
                    dr = dr + 1.0
                  endif
                endif

Done at the start of each iteration i.e. using magn from the previous one - note that this should be the true magnitude not the square.

Yes, you are correct that to render the surface based solely on the distance estimate then ideally the max iteration value should be set so that no points tested on the ray actually reach max iterations - though this possibility must be allowed for due to possible over-stepping as you say.
The simple solution is to assume "solid" is either the point at the correct distance threshold or the nearest point to the viewer that reaches the maximum iteration count.
In fact using DE works quite well even if you want to view the true iteration iso-surface (i.e. have "solid" at a given iteration count) at least at lower iterations (typically <20), all a user need to do here (if programmed correctly) is set the threshold distance to (near) zero but set the max iterations value to set the iso-surface you want to be solid.

Logged

The meaning and purpose of life is to give life purpose and meaning.

http://www.fractalgallery.co.uk/
"Makin' Magic Music" on Jango
barkeg
Alien
***
Posts: 29



« Reply #14 on: August 13, 2011, 01:29:56 AM »

ok, but dr isn't the distance right? The distance I have to calculate finally by

distance = r * log(r) / dr

and maybe some factor more I think.

by the way log(r) to which base is it (I have a little  confusion there because everyone put's it like he wants)?

So if I have a hybrid fractal with first a mandelbox transformation and later a trig. mandelbulb where can I put the
"dr = @mpwr*dr*magn^(@mpwr-1.0)"?

Some pseudo code I thought:

Code:
iteration loop

    mandelbox folding and calculating DEfactor

    distance = sqrt(x*x+y*y+z*z)/abs(DEfactor)

    Mandelbulb transformation
    
    dr = @mpwr*dr*oldmagn^(@mpwr-1.0)

   distance = r * log(r) / dr

   oldmagn=magn

next loop

but doing it like this I don't need to calculate the DEfactor and the distance after the mandelbox folding. I also though of caluclating the dr after the mandelbox part by using the forumla at the end and calculate DEfactor ad the beginning:

Code:
iteration loop

    DEfactor=sqrt(x*x+y*y+z*z)/distance   <--------------------------

    mandelbox folding and calculating DEfactor

    distance = sqrt(x*x+y*y+z*z)/abs(DEfactor)

    dr= r*log(r)/distance       <-------------------------------------------

    Mandelbulb transformation
    
    dr = @mpwr*dr*oldmagn^(@mpwr-1.0)

   distance = r * log(r) / dr

   oldmagn=magn

next loop

I mean it's the same problem as before...I don't know how to deal with the DEfactor

can I use the magn after the mandelbox part or has it to be the final value of the iteration loop before?

Well, I really appreciate that you're taking the time to solve my doubt's! cheesy
« Last Edit: August 13, 2011, 01:34:10 AM by barkeg » Logged
Pages: [1] 2   Go Down
  Print  
 
Jump to:  


Powered by MySQL Powered by PHP Powered by SMF 1.1.21 | SMF © 2015, Simple Machines

Valid XHTML 1.0! Valid CSS! Dilber MC Theme by HarzeM
Page created in 0.262 seconds with 27 queries. (Pretty URLs adds 0.015s, 2q)