Coloring Julia Sets using Distance Estimation Relative to Zoom Depth

297 Views Asked by At

Using the distance estimation coloring algorithm learned from here, I was able to color Julia Sets projected on a Riemann sphere, as with this video. However, once I started displaying polynomial matings of Julia Sets, using this coloring algorithm provided inconsistent results, as shown in the first image below. Certain parts are clearer than others, and this is because the polynomial mating brings out deeper parts of the fractal without zooming in, and so using the same distance adjustment makes those zoomed in parts more "blurry" than the rest.

As such, what I think I need is some sort of algorithm to detect how "zoomed in" I am in the Julia set, so I can adjust the distance accordingly. I tried basing it off of how many iterations it takes for the orbit to escape (as the deeper you get, the more iterations it takes for the orbit to escape) but that didn't quite get the intended effect (second image below - certain parts are barely visible). Here is my code for the coloring:

for (iter = currentMatingIteration + 1; iter < maxIterations && (w.x * w.x + w.y * w.y < bailout*bailout); iter++)
{
    d2 *= 4.0 * w2;
    
    // Julia Set algorithm
    w = c_2(w) + c;

    w2 = w.x * w.x + w.y * w.y;

    // Distance checker
    if(w2 > maxDist)
        break;
}

float fineness = 7;     // the higher, the less "blurry"
//float fineness = 15;  // this is used for the second picture below

float d = sqrt(w2 / d2) * log(w2);  // this is the distance estimation
float dist = clamp(sqrt(d * pow(fineness, 2)), 0, 1);   // this is the adjustments I make for coloring

//float dist = clamp(sqrt(d * pow(fineness * (float(iter) / maxIterations), 2)), 0, 1);     // This is my attempt to solve this problem, used in the second picture below

My project is here for testing.

enter image description here enter image description here

Edit:

While this probably isn't a general solution to figuring out how deeply zoomed one is, what worked for this issue is calculating the derivative during the pull-back part of the mating algorithm, and using that as the initial value for calculating the distance estimation for each Julia Set (thanks to Claude in the comments). The successful result is below:

enter image description here enter image description here

Riemann Sphere Adjustment

Without adjustment: enter image description here

With adjustment: enter image description here

1

There are 1 best solutions below

1
On

The key point when generating distance estimated images is to base the derivatives relative to the correct scale. For a typical 2D Julia set or Mandelbrot set image one takes derivatives relative to pixel spacing (really, including the transformation from pixel coordinates to complex plane into account when calculating derivatives with the chain rule).

Images need not have a simple linear mapping from pixels, for example your projections of the Riemann sphere in 3D. Probably there is some need to take into account the stereographic projection, but perhaps the distortion is not too big for the region near 0. Ideally derivatives (and thus distance estimates) would be scaled relative to surface distance on the sphere surface in 3D.