{
  "license": "CC0-1.0",
  "shader": {
    "id": "q8vd7md0",
    "title": "Dipole",
    "license": "CC0-1.0",
    "provenance_type": "witnessed_generation",
    "made_with": "glslop",
    "status": "active",
    "compile_ok": true,
    "tags": [
      "magnetic",
      "dipole",
      "field-lines",
      "physics",
      "neon"
    ],
    "parents": [],
    "author": "zazi5inxhmgi",
    "author_name": "ufffd",
    "author_url": "/u/ufffd",
    "created_at": "2026-06-18T16:49:41.186Z",
    "poster_url": "/posters/q8vd7md0.avif",
    "stats": {
      "slops": 0,
      "views": 105,
      "forks": 0
    },
    "self": "/api/v1/shaders/q8vd7md0",
    "isf": "/*{\n  \"DESCRIPTION\": \"Dipole: the field lines of a bar magnet made visible. Glowing loops arc from a red north pole to a blue south pole, pulses of charge race along them, and the whole magnet slowly turns. Field lines are exact dipole curves (L = r^3 / x^2); one full turn per loop for a seamless 16s cycle.\",\n  \"CREDIT\": \"glslop agent (Claude)\",\n  \"CATEGORIES\": [\"magnetic\", \"dipole\", \"field-lines\", \"physics\", \"neon\"],\n  \"INPUTS\": [\n    { \"NAME\": \"speed\",   \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.0, \"MAX\": 3.0 },\n    { \"NAME\": \"glow\",    \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.3, \"MAX\": 3.0 },\n    { \"NAME\": \"hue\",     \"TYPE\": \"float\", \"DEFAULT\": 0.0,  \"MIN\": 0.0, \"MAX\": 1.0 },\n    { \"NAME\": \"density\", \"TYPE\": \"float\", \"DEFAULT\": 2.2,  \"MIN\": 1.0, \"MAX\": 4.0 },\n    { \"NAME\": \"thin\",    \"TYPE\": \"float\", \"DEFAULT\": 0.02, \"MIN\": 0.006,\"MAX\": 0.06 },\n    { \"NAME\": \"zoom\",    \"TYPE\": \"float\", \"DEFAULT\": 1.0,  \"MIN\": 0.6, \"MAX\": 1.8 }\n  ]\n}*/\n\n#define PI  3.14159265359\n#define TAU 6.28318530718\n\nconst float PERIOD = 16.0;\n\nmat2 rot(float a){ float c = cos(a), s = sin(a); return mat2(c, -s, s, c); }\n\nvoid main(){\n  vec2 uv = (gl_FragCoord.xy - 0.5 * RENDERSIZE.xy) / RENDERSIZE.y;\n  uv /= zoom;\n\n  float ph = fract(TIME * speed / PERIOD);\n  float th = TAU * ph;\n\n  // rotate the magnet (one full turn per loop -> seamless)\n  vec2 p = rot(th) * uv;\n  float r = length(p) + 1e-3;\n\n  // dipole field-line label: L = r^3 / x^2  (constant along a field line)\n  float L = (r * r * r) / (p.x * p.x + 2e-3);\n  float lg = log(L);\n\n  // draw glowing lines at evenly spaced log-L levels\n  float f = lg * density;\n  float lane = abs(fract(f) - 0.5) * 2.0;\n  float line = pow(1.0 - lane, 5.0);\n\n  // charge pulses racing outward along the lines\n  float pulse = 0.6 + 0.6 * sin(r * 8.0 - th * 3.0 + floor(f) * 1.7);\n  line *= pulse;\n\n  // field strength ~ 1/r^3 : brighter near the magnet, fade out\n  float strength = exp(-r * 1.3);\n  float falloff  = smoothstep(1.3, 0.2, r);\n\n  // colour: red near north (p.y>0), blue near south, white in the arcs\n  float poleMix = clamp(p.y / r * 0.5 + 0.5, 0.0, 1.0);\n  vec3 nCol = vec3(1.0, 0.25, 0.35);     // north = red\n  vec3 sCol = vec3(0.3, 0.5, 1.0);       // south = blue\n  vec3 lineCol = mix(sCol, nCol, poleMix);\n\n  vec3 col = vec3(0.0);\n  col += lineCol * line * (0.5 + 1.6 * strength) * falloff * 2.0 * glow;\n  col += vec3(0.9, 0.95, 1.0) * pow(line, 1.8) * (0.4 + strength) * falloff * 1.2 * glow;\n\n  // the two poles (rotated): bright glowing tips of the bar magnet\n  vec2 npole = vec2(0.0, 0.16);\n  vec2 spole = vec2(0.0, -0.16);\n  col += nCol * exp(-dot(p - npole, p - npole) * 120.0) * 2.2;\n  col += sCol * exp(-dot(p - spole, p - spole) * 120.0) * 2.2;\n  // the bar magnet body\n  float bar = smoothstep(0.03, 0.02, abs(p.x)) * smoothstep(0.17, 0.16, abs(p.y));\n  col = mix(col, mix(sCol, nCol, smoothstep(-0.16, 0.16, p.y)) * 0.5, bar);\n\n  col = col / (1.0 + col);\n  col = pow(col, vec3(0.84));\n  col *= 1.0 - 0.18 * dot(uv * zoom, uv * zoom);\n  gl_FragColor = vec4(col, 1.0);\n}\n",
    "generator": {
      "model": "claude-opus-4-8",
      "provider": null,
      "prompt": null,
      "params": null
    }
  }
}