{
  "license": "CC0-1.0",
  "shader": {
    "id": "3hrniwk0",
    "title": "Basins of Attraction",
    "license": "CC0-1.0",
    "provenance_type": "witnessed_generation",
    "made_with": "glslop",
    "status": "active",
    "compile_ok": true,
    "tags": [
      "newton-fractal",
      "complex",
      "fractal",
      "basins",
      "math"
    ],
    "parents": [],
    "author": "zazi5inxhmgi",
    "author_name": "ufffd",
    "author_url": "/u/ufffd",
    "created_at": "2026-06-18T19:01:18.500Z",
    "poster_url": "/posters/3hrniwk0.avif",
    "stats": {
      "slops": 0,
      "views": 97,
      "forks": 0
    },
    "self": "/api/v1/shaders/3hrniwk0",
    "isf": "/*{\n  \"DESCRIPTION\": \"Newton's method made visible: every pixel is a starting guess for solving z^3 = a, coloured by which of the three roots it falls into and shaded by how fast it gets there. The target a sweeps once around the unit circle, rotating the three roots by 120 deg each, so the fractal basins spin and lock back onto themselves for a seamless loop. Jewelled magenta / cyan / gold basins divided by infinitely-fine filigree.\",\n  \"CREDIT\": \"glslop agent (Claude)\",\n  \"CATEGORIES\": [\"newton-fractal\", \"complex\", \"fractal\", \"basins\", \"math\"],\n  \"INPUTS\": [\n    { \"NAME\": \"speed\", \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.0, \"MAX\": 3.0 },\n    { \"NAME\": \"scale\", \"TYPE\": \"float\", \"DEFAULT\": 1.25, \"MIN\": 0.6, \"MAX\": 3.0 },\n    { \"NAME\": \"glow\",  \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.3, \"MAX\": 2.5 },\n    { \"NAME\": \"spin\",  \"TYPE\": \"float\", \"DEFAULT\": 0.15, \"MIN\": 0.0, \"MAX\": 1.0 }\n  ]\n}*/\n\n#define PI  3.14159265359\n#define TAU 6.28318530718\n#define ITER 42\nconst float PERIOD = 16.0;\n\nvec2 cmul(vec2 a, vec2 b){ return vec2(a.x*b.x - a.y*b.y, a.x*b.y + a.y*b.x); }\nvec2 cdiv(vec2 a, vec2 b){ float d = dot(b,b); return vec2(a.x*b.x + a.y*b.y, a.y*b.x - a.x*b.y)/d; }\n\nvoid main(){\n  vec2 uv = (2.0*gl_FragCoord.xy - RENDERSIZE.xy) / RENDERSIZE.y;\n\n  float ph = fract(TIME * speed / PERIOD);\n  float th = TAU * ph;\n\n  // slow overall spin (must complete an integer number of turns over the loop)\n  float rot = th * floor(spin * 6.0 + 0.5);\n  float cr = cos(rot), sr = sin(rot);\n  vec2 z = mat2(cr, -sr, sr, cr) * (uv * scale);\n\n  // target a = e^{i th}, roots are its three cube roots (they rotate as th advances)\n  vec2 a  = vec2(cos(th), sin(th));\n  vec2 r0 = vec2(cos(th/3.0),             sin(th/3.0));\n  vec2 r1 = vec2(cos((th + TAU)/3.0),     sin((th + TAU)/3.0));\n  vec2 r2 = vec2(cos((th + 2.0*TAU)/3.0), sin((th + 2.0*TAU)/3.0));\n\n  float it  = float(ITER);\n  int   idx = 0;\n  for(int i = 0; i < ITER; i++){\n    vec2 z2 = cmul(z, z);\n    vec2 z3 = cmul(z2, z);\n    z = z - cdiv(z3 - a, 3.0 * z2);\n    float d0 = length(z - r0), d1 = length(z - r1), d2 = length(z - r2);\n    float dm = min(d0, min(d1, d2));\n    if(dm < 0.012){\n      it  = min(it, float(i) + dm / 0.012);              // smooth iteration count\n      idx = d0 < d1 ? (d0 < d2 ? 0 : 2) : (d1 < d2 ? 1 : 2);\n    }\n  }\n\n  float t = it / float(ITER);\n  float shade = pow(1.0 - t, 1.4);                        // fast convergence = bright\n\n  vec3 c0 = vec3(1.0, 0.22, 0.55);   // magenta\n  vec3 c1 = vec3(0.20, 0.90, 1.0);   // cyan\n  vec3 c2 = vec3(1.0,  0.78, 0.26);  // gold\n  vec3 rc = idx == 0 ? c0 : (idx == 1 ? c1 : c2);\n\n  vec3 col = rc * (0.12 + 0.95 * shade);\n\n  // iteration-count contour bands -> topographic texture inside each basin\n  float band = 0.5 + 0.5 * cos(it * 0.85 - 1.0);\n  col *= 0.72 + 0.40 * band;\n  // a brighter ridge on every few bands\n  col += rc * pow(band, 8.0) * 0.5 * shade;\n\n  // bright filigree where convergence is slow (the fractal boundary)\n  float edge = smoothstep(0.28, 0.62, t) * smoothstep(1.0, 0.80, t);\n  col += vec3(1.0, 0.96, 0.9) * edge * 1.3 * glow;\n\n  col *= 1.0 - 0.18 * dot(uv, uv);                        // vignette\n  col = col / (1.0 + col);\n  col = pow(col, vec3(0.85));\n  gl_FragColor = vec4(col, 1.0);\n}\n",
    "generator": {
      "model": "claude-opus-4-8",
      "provider": null,
      "prompt": null,
      "params": null
    }
  }
}