Skip to the plate
FORMA PUBLIC DOMAIN GENERATIVE ATLAS / ED. 0.28
Plate 14, Julia Set: a still of the escape time / fixed c plate as the atlas renders it, in the fractals accent.

PL. 14  ·  FRACTALS / ESCAPE TIME / FIXED C

Julia Set

Gaston Julia, 1918 · Pierre Fatou, 1917

OPEN THE LIVE PLATE ▸

DEFINITION

zₙ₊₁ = zₙ² + c,  z₀ = pixel
c = μ/2 − μ²/4,  μ = |μ|·e^(iθ)

NOTES

The same iteration as the Mandelbrot set with the roles swapped: c is fixed and the starting point varies. Every c gives a different Julia set, and the Mandelbrot set is precisely the map of which ones are connected. Julia worked all of this out without ever seeing one drawn.

PROVENANCE

Origin
Gaston Julia, Journal de Mathématiques Pures et Appliquées, 1918
Standing
Public domain — a century old
Constants
|μ| under 1 keeps c inside the main cardioid, so the set stays connected; over 1 breaks it into dust

TOUCHDESIGNER · GLSL

The same shader this plate runs, reframed for a GLSL TOP. Pasted bare it renders the published constants as a still frame; wire absTime.seconds into u_t on the Vectors page to animate it.

// FORMA — PL. 14 · JULIA SET — Gaston Julia, 1918 · Pierre Fatou, 1917
//   zₙ₊₁ = zₙ² + c,  z₀ = pixel
//   c = μ/2 − μ²/4,  μ = |μ|·e^(iθ)
// TouchDesigner port — paste into a GLSL TOP's pixel shader. Set the
// resolution on the TOP's Common page. As pasted it renders the published
// constants as a still frame; to animate, add a uniform named u_t on the
// GLSL TOP's Vectors 1 page with the expression absTime.seconds.
// Constants are consts — edit to tweak; comments give the measured range.
// Written from the published mathematics, not adapted from any code.

#define u_res (uTDOutputInfo.res.zw)
uniform float u_t;               // absTime.seconds on the Vectors page; unset = still

const float u_phase = 0.0955;    // this plate's own grid phase, 0..1
// FORMA's FRACTALS accent as cosine-gradient coefficients
const vec3 u_pal_a = vec3(0.46, 0.1389, 0.1912);
const vec3 u_pal_b = vec3(0.5, 0.151, 0.2078);
const vec3 u_pal_c = vec3(1, 1, 1);
const vec3 u_pal_d = vec3(0, 0.05, 0.1);

const float p_r    = 0.99;        // |μ| — distance to the cardioid · live 0.85 .. 1.06
const float p_ang  = 150.0;       // arg c (°) · live 0 .. 360
const float p_iter = 160.0;       // iteration ceiling · live 40 .. 400
const float p_spin = 1.0;         // rotate c · live 0 .. 1
const float p_dive = 1.6;         // dive — decades of zoom · live 0 .. 2.5

/* The order's ramp — the same cosine formulation the JS kit uses, so a
   plate keeps its classification colour in either language. */
vec3 ramp(float t){
  return clamp(u_pal_a + u_pal_b * cos(6.28318530718 * (u_pal_c * t + u_pal_d)), 0.0, 1.0);
}

/* Sawtooth and triangle on this plate's phase, mirroring the JS kit. */
float cycle(float t, float period){ return fract(t / period + u_phase); }
float pingpong(float t, float period){
  float u = cycle(t, period);
  return u < 0.5 ? u * 2.0 : 2.0 - u * 2.0;
}


vec3 plate(vec2 uv){
  /* c on the main cardioid, c = mu/2 - mu*mu/4, so every angle stays inside
     the Mandelbrot set and the Julia set stays connected. */
  float a = p_ang * 3.141592653589793 / 180.0
          + (p_spin > 0.5 ? u_t * 0.1 + u_phase * 6.283 : 0.0);
  float mu = p_r * (0.985 + pingpong(u_t, 19.0) * 0.03);   // breathes across the boundary
  float mr = mu * cos(a), mi = mu * sin(a);
  float cr = mr / 2.0 - (mr * mr - mi * mi) / 4.0;
  float ci = mi / 2.0 - (mr * mi) / 2.0;

  /* The dive: the window sinks toward the repelling fixed point
     beta = (1 + sqrt(1 - 4c))/2, the plate's own anchor, and returns.
     Same camera as the JS path, decade for decade. */
  float wr = 1.0 - 4.0 * cr, wi = -4.0 * ci;
  float rad = length(vec2(wr, wi));
  float sr = sqrt(max(0.0, (rad + wr) / 2.0));
  float si = (wi >= 0.0 ? 1.0 : -1.0) * sqrt(max(0.0, (rad - wr) / 2.0));
  float bx = 0.5 + sr / 2.0, by = si / 2.0;
  float Z = pow(10.0, p_dive * pingpong(u_t, 24.0));
  float span = 3.2 / Z;
  /* Depth needs iterations — the JS path's scaling, same 400 ceiling. */
  float it = min(400.0, floor(p_iter * (1.0 + log2(Z) * 0.5) + 0.5));

  float zr = bx * (1.0 - 1.0 / Z) + (uv.x - 0.5) * span;
  float zi = by * (1.0 - 1.0 / Z) + (uv.y - 0.5) * span * (u_res.y / u_res.x);
  float n = 0.0;
  for (int i = 0; i < 400; i++){        // 400 is the slider's own ceiling
    if (float(i) >= it || zr * zr + zi * zi >= 4.0) break;
    float tmp = zr * zr - zi * zi + cr;
    zi = 2.0 * zr * zi + ci;
    zr = tmp;
    n += 1.0;
  }
  if (n >= it) return vec3(4.0, 6.0, 10.0) / 255.0;
  /* Continuous dwell, then the log remap — the same mapping the JS path
     lays down, and the same the whole escape family now shares. */
  float nu = n + 1.0 - log2(log(zr * zr + zi * zi) / 2.0);
  float g = log(1.0 + max(0.0, nu)) / log(1.0 + it);
  return ramp(0.44 + 0.62 * g);
}

out vec4 fragColor;
void main(){
  // FORMA's uv runs y-down, matching its canvas; TD's vUV runs up
  vec2 uv = vec2(vUV.s, 1.0 - vUV.t);
  fragColor = TDOutputSwizzle(vec4(plate(uv), 1.0));
}

NUKE · BLINKSCRIPT

The same shader this plate runs, transpiled to a BlinkScript kernel. Paste it into a BlinkScript node's Kernel Source and press Recompile; every constant arrives as a knob at its published value, and u_t animates with the expression frame/24. Compiled and rendered in Nuke 17.1, then compared against this plate on the page.

// FORMA — PL. 14 · JULIA SET — Gaston Julia, 1918 · Pierre Fatou, 1917
//   zₙ₊₁ = zₙ² + c,  z₀ = pixel
//   c = μ/2 − μ²/4,  μ = |μ|·e^(iθ)
// Nuke port — a BlinkScript kernel. Paste into a BlinkScript node's Kernel
// Source and press Recompile. Every constant arrives as a knob at its published
// value (the comment gives the measured range); u_t is a knob too — animate it
// with the expression frame/24 or leave it at 0 for the still frame. Written
// from the published mathematics, not adapted from any code.
// Transpiled from the shader this plate runs on the page (GLSL ES 3.00):
// vec → float2/3/4, swizzles expanded, GLSL builtins Blink lacks written out
// as forma_ functions, float literals suffixed. Compiled and rendered in a
// real Nuke (17.1v1) and compared against this plate on the page: 34 of 34.
//
// plate() and its helpers are written to a single exit — the loop that runs
// once. That is not a style: Blink 17.1 drops a conditional early return from
// a called function while Vectorize is on, which is the node default, with no
// warning and no error. Written this way it paints correctly as pasted.

kernel Forma_julia : ImageComputationKernel<ePixelWise>
{
  Image<eWrite> dst;

param:
  float u_t;             // seconds; 0 is the still frame
  float p_r;    // |μ| — distance to the cardioid · live 0.85 .. 1.06
  float p_ang;  // arg c (°) · live 0 .. 360
  float p_iter; // iteration ceiling · live 40 .. 400
  float p_spin; // rotate c · live 0 .. 1
  float p_dive; // dive — decades of zoom · live 0 .. 2.5

local:
  float2 u_res;
  float u_phase;
  float3 u_pal_a, u_pal_b, u_pal_c, u_pal_d;

  void define(){
    defineParam(u_t, "u_t", 0.0f);
    defineParam(p_r, "p_r", 0.99f);
    defineParam(p_ang, "p_ang", 150.0f);
    defineParam(p_iter, "p_iter", 160.0f);
    defineParam(p_spin, "p_spin", 1.0f);
    defineParam(p_dive, "p_dive", 1.6f);
  }

  void init(){
    u_res = float2(float(dst.bounds.width()), float(dst.bounds.height()));
    u_phase = 0.0955f;    // this plate's own grid phase, 0..1
    // FORMA's FRACTALS accent as cosine-gradient coefficients
    u_pal_a = float3(0.46f, 0.1389f, 0.1912f);
    u_pal_b = float3(0.5f, 0.151f, 0.2078f);
    u_pal_c = float3(1.0f, 1.0f, 1.0f);
    u_pal_d = float3(0.0f, 0.05f, 0.1f);
  }

  /* GLSL builtins Blink lacks, written as templates rather than overload sets.
     Blink's operators return expression templates (Swizzle<float,N>), so a call
     passing an expression cannot resolve against an overload set on float2
     against float3 — measured in Nuke 17.1: a float2 expression is ambiguous
     between the two, while scalar-against-vector resolves. A template deduces
     the expression's own type, so the ambiguity cannot arise. */
  template <class T> T forma_fract(T v){ return v - floor(v); }
  template <class T, class S> T forma_mod(T x, S y){ return x - y * floor(x / y); }
  /* Blink's own min/max/clamp take no scalar bound against a vector, which GLSL
     does; v * 0.0f + b is that bound at the vector's own width, and collapses to
     b when v is a scalar, so one template serves both. */
  template <class T, class S> T forma_min(T a, S b){ return min(a, a * 0.0f + b); }
  template <class T, class S> T forma_max(T a, S b){ return max(a, a * 0.0f + b); }
  template <class T, class S> T forma_clamp(T v, S lo, S hi){ return clamp(v, v * 0.0f + lo, v * 0.0f + hi); }
  int forma_min(int a, int b){ return min(a, b); }
  int forma_max(int a, int b){ return max(a, b); }
  /* GLSL step(edge, x) is 1 where x >= edge; floor(sign(x - e) * 0.5 + 1) is
     that exactly, equality included, out of builtins Blink does have. */
  template <class T, class S> T forma_step(S e, T x){ return floor(sign(x - e) * 0.5f + 1.0f); }
  template <class T, class S> T forma_smoothstep(S a, S b, T x){
    T t = forma_clamp((x - a) / (b - a), 0.0f, 1.0f);
    return t * t * (3.0f - 2.0f * t);
  }
  template <class T> float forma_distance(T a, T b){ return length(a - b); }
  float forma_tanh(float x){ float e = exp(2.0f * x); return (e - 1.0f) / (e + 1.0f); }
  float forma_radians(float d){ return d * 0.01745329252f; }
  // the page's hash2 is exact uint32; Blink has int, so the shifts are made
  // logical by masking and the read-back is lifted into 0 .. 2^32
  /* A uint read back as a float. Blink has no unsigned type, so a value past
     2^31 arrives as a negative int and float() of it is negative. Measured on
     gabor, whose own generator then returned uniforms in [-0.5, 0.5) and drew
     a different picture — it compiled, it rendered, and only comparing it with

  /* The order's ramp — the same cosine formulation the JS kit uses, so a
     plate keeps its classification colour in either language. */
  float3 ramp(float t){
    return forma_clamp(u_pal_a + u_pal_b * cos(6.28318530718f * (u_pal_c * t + u_pal_d)), 0.0f, 1.0f);
  }

  /* Sawtooth and triangle on this plate's phase, mirroring the JS kit. */
  float cycle(float t, float period){ return forma_fract(t / period + u_phase); }
  float pingpong(float t, float period){
    float u = cycle(t, period);
    return u < 0.5f ? u * 2.0f : 2.0f - u * 2.0f;
  }


  float3 plate(float2 uv){
    float3 forma_r = float3(0.0f, 0.0f, 0.0f);
    for (int forma_once = 0; forma_once < 1; forma_once++){
      /* c on the main cardioid, c = mu/2 - mu*mu/4, so every angle stays inside
         the Mandelbrot set and the Julia set stays connected. */
      float a = p_ang * 3.141592653589793f / 180.0f
              + (p_spin > 0.5f ? u_t * 0.1f + u_phase * 6.283f : 0.0f);
      float mu = p_r * (0.985f + pingpong(u_t, 19.0f) * 0.03f);   // breathes across the boundary
      float mr = mu * cos(a);
      float mi = mu * sin(a);
      float cr = mr / 2.0f - (mr * mr - mi * mi) / 4.0f;
      float ci = mi / 2.0f - (mr * mi) / 2.0f;

      /* The dive: the window sinks toward the repelling fixed point
         beta = (1 + sqrt(1 - 4c))/2, the plate's own anchor, and returns.
         Same camera as the JS path, decade for decade. */
      float wr = 1.0f - 4.0f * cr;
      float wi = -4.0f * ci;
      float rad = length(float2(wr, wi));
      float sr = sqrt(forma_max(0.0f, (rad + wr) / 2.0f));
      float si = (wi >= 0.0f ? 1.0f : -1.0f) * sqrt(forma_max(0.0f, (rad - wr) / 2.0f));
      float bx = 0.5f + sr / 2.0f;
      float by = si / 2.0f;
      float Z = pow(10.0f, p_dive * pingpong(u_t, 24.0f));
      float span = 3.2f / Z;
      /* Depth needs iterations — the JS path's scaling, same 400 ceiling. */
      float it = forma_min(400.0f, floor(p_iter * (1.0f + log2(Z) * 0.5f) + 0.5f));

      float zr = bx * (1.0f - 1.0f / Z) + (uv.x - 0.5f) * span;
      float zi = by * (1.0f - 1.0f / Z) + (uv.y - 0.5f) * span * (u_res.y / u_res.x);
      float n = 0.0f;
      for (int i = 0; i < 400; i++){        // 400 is the slider's own ceiling
        if (float(i) >= it || zr * zr + zi * zi >= 4.0f) break;
        float tmp = zr * zr - zi * zi + cr;
        zi = 2.0f * zr * zi + ci;
        zr = tmp;
        n += 1.0f;
      }
      if (n >= it) { forma_r = float3(4.0f, 6.0f, 10.0f) / 255.0f; break; }
      /* Continuous dwell, then the log remap — the same mapping the JS path
         lays down, and the same the whole escape family now shares. */
      float nu = n + 1.0f - log2(log(zr * zr + zi * zi) / 2.0f);
      float g = log(1.0f + forma_max(0.0f, nu)) / log(1.0f + it);
      { forma_r = ramp(0.44f + 0.62f * g); break; }
    }
    return forma_r;
  }

  void process(int2 pos){
    // FORMA's uv runs y-down like its canvas; Nuke's rows run up
    float2 uv = float2((float(pos.x) + 0.5f) / u_res.x, 1.0f - (float(pos.y) + 0.5f) / u_res.y);
    float3 c = plate(uv);
    dst() = float4(c.x, c.y, c.z, 1.0f);
  }
};