Welcome to Fractal Forums

Fractal Software => Programming => Topic started by: TruthSerum on July 05, 2014, 04:57:45 PM




Title: Mandelbulb directional distance
Post by: TruthSerum on July 05, 2014, 04:57:45 PM
I've been using this algorithm to improve the results of the DE step search.

Code:
    bool yams(const Vector& a, const Vector& b, Real* x, Real* e) {
      if (m(a)) {
        return false; /* ray starts inside the Mandelbulb */
      }
      /* locate the surface with DE steps */
      Real min = 0;
      Real max = 0;
      bool found = false;
      for (int i = 0; i < 128; ++i) {
        Real next = min + md(a.add(b.mul(min))) * 0.1;
        if (m(a.add(b.mul(next)))) {
          max = next;
          found = true;
          break;
        }
        min = next;
      }
      if (!found) { /* unable to locate surface */
        *x = min;
        *e = 0;
        return true;
      }
      /* solution refinement */
      for (int i = 0; i < 128; ++i) {
        Real mid = (min + max) * 0.5;
        if (m(a.add(b.mul(mid)))) {
          max = mid;
        } else {
          min = mid;
        }
      }
      *x = min;
      *e = max - min;
      return true;
    }

After the surface is found using DE steps, it then refines the solution by bisection/binary search to "back up" to where the ray hits the surface.

It depends on having the boolean version of the Mandelbulb surface functioin, m(), available.

The function md() is the common log|arg| * |arg| / |de| distance metric.

It returns false if the ray does not hit the surface, and true otherwise.

If the intersection is found, then the variable 'x' contains the distance along the line a + b * x to the intersection, and e contains the error with the intention that

m(a + b * x) == false

and

m(a + b * (x+e)) == true

where e is as small as possible.

Let me know what you think :)

(http://i.imgur.com/qJ1IpXI.png)

And here are some graphs from my analysis:

(http://i.imgur.com/4DfdZs1.png)

(http://i.imgur.com/An2bGv4.png)

The white line shows the distance function |arg| as the ray approaches the surface.
The green lines mark the areas of the x-axis that are contained inside the surface.
The blue line marks the solution.


Title: Re: Mandelbulb directional distance
Post by: David Makin on July 06, 2014, 02:27:31 AM
Using a binary search to refine the surface intersection has been done in DE algorithms since before anyone started the analytical versions.


Title: Re: Mandelbulb directional distance
Post by: TruthSerum on July 06, 2014, 02:03:53 PM
I don't know about the history of the techniques.

What is the current state of research?

Which fractal algorithms currently lack analytic solutions that are worth investigating?


Title: Re: Mandelbulb directional distance
Post by: David Makin on July 07, 2014, 12:24:30 AM
With respect to the Mandelbulb Triplex the only ones that I'm sure aren't close to "correct" yet are ones that aren't exactly defined anyway even as plain triplex math - i.e. many of the higher functions.
For more normal maths such as Quaternions and Bicomplex (also often just referred to a hypercomplex - but basically the "squarry" ones) the analytical DE is virtually as straightforward as plain complex, however if you start playing with conditionals and the like it will break down - especially in cases of breaks in iteration smoothness i.e. where a fractal jumps from say 10 iterations to 12 on neighbouring locations even in the infinite limit - essentially fractal discontinuities,
The fractal type I would love to nail with respect to accurate analytical DE would be full escape-time IFS with affine transforms that include rotations/skews/shears as well as scaling and translation and with varied scaling across the 3 or more dimensions - at the moment to make this accurate requires very high bailouts for objects such as a 3D Barnsley fern making rendering slow - the more varied the scaling *from one axis/dimension* to another in any of the transforms the more inaccurate the DE becomes, a way round this without huge calculation overhead would be very helpful - especially now folks are mixing all types of fractal together.

With respect to the binary search - I only find it necessary when deliberately not rendering fractals to the full screen resolution i.e. when the DE "solid" threshold is greater than half a screen pixel, in such cases without the binary search there will be noticeable "stepping" in the illumination due to inaccuracy of surface normal calculation, using the binary search eliminates this but often if rendering to best resolution for the display size the DE threshold distance can simply be reduced to the point where the stepping from surface normal accuracy vanishes anyway.