{
  "license": "CC0-1.0",
  "shader": {
    "id": "chwj7cww",
    "title": "Warp Conduit",
    "license": "CC0-1.0",
    "provenance_type": "user_upload",
    "made_with": "glslop",
    "status": "active",
    "compile_ok": true,
    "tags": [
      "raymarch",
      "tunnel",
      "3d",
      "depth",
      "scifi"
    ],
    "parents": [],
    "author": "zazi5inxhmgi",
    "author_name": "ufffd",
    "author_url": "/u/ufffd",
    "created_at": "2026-06-16T16:38:23.615Z",
    "poster_url": "/posters/chwj7cww.avif",
    "stats": {
      "slops": 0,
      "views": 135,
      "forks": 1
    },
    "self": "/api/v1/shaders/chwj7cww",
    "isf": "/*{\n  \"DESCRIPTION\": \"Warp Conduit — a raymarched flight down an endless twisting tube. The tunnel axis snakes through space and the faceted wall is carved with rings and flutes that sweep past for parallax; a glowing filament runs down the throat. Pure SDF, GLSL ES 1.00.\",\n  \"CREDIT\": \"glslop loop iter3\",\n  \"CATEGORIES\": [\"raymarch\", \"3d\", \"tunnel\"],\n  \"INPUTS\": [\n    { \"NAME\": \"speed\",  \"TYPE\": \"float\", \"DEFAULT\": 1.0, \"MIN\": 0.0, \"MAX\": 3.0 },\n    { \"NAME\": \"twist\",  \"TYPE\": \"float\", \"DEFAULT\": 1.0, \"MIN\": 0.0, \"MAX\": 3.0 },\n    { \"NAME\": \"glow\",   \"TYPE\": \"color\", \"DEFAULT\": [0.30, 0.70, 1.0, 1.0] }\n  ]\n}*/\n\n// ---- helpers (ES 1.00 safe: no round/tanh/dFdx, constant loop bounds) ----\n\nmat2 rot(float a){\n  float c = cos(a), s = sin(a);\n  return mat2(c, -s, s, c);\n}\n\n// the wandering center of the tunnel at depth z (gives parallax + a snaking path)\nvec2 tunnelCenter(float z){\n  return vec2(sin(z * 0.30) * 0.55, cos(z * 0.23) * 0.55);\n}\n\n// Distance field of the conduit. The camera flies down the INSIDE of a hollow tube\n// whose axis snakes through space; the wall is at radius `tube` from that axis, so\n// (tube - r) is the (signed) distance to the wall from inside. Rings + flutes carve\n// relief into the wall. No geometry sits on the axis, so the camera never self-hits.\nfloat mapScene(vec3 p){\n  vec2 ctr = tunnelCenter(p.z);\n  vec2 pc = p.xy - ctr;\n\n  // corkscrew twist increases with depth so the ribs spiral as you fly\n  pc = rot(p.z * 0.25 * twist) * pc;\n\n  float r = length(pc);\n  float ang = atan(pc.y, pc.x);\n\n  float tube  = 1.35 + 0.12 * sin(p.z * 0.5);        // breathing radius\n  float rings = 0.12 * sin(p.z * 3.0);               // grooves along the run\n  float flutes = 0.06 * sin(ang * 8.0 + p.z * 1.5);  // angular ridges -> facets\n\n  // inside the tube, distance to the wall:\n  return (tube + rings + flutes) - r;\n}\n\nvoid main(){\n  vec2 uv = (gl_FragCoord.xy - 0.5 * RENDERSIZE.xy) / RENDERSIZE.y;\n\n  float t = TIME * speed;\n\n  // camera rides the snaking tunnel axis\n  float z = t * 2.4;\n  vec3 ro = vec3(tunnelCenter(z), z);\n\n  // forward = tangent of the axis path (so we lean into the bends)\n  float dz = 0.35;\n  vec3 axisAhead = vec3(tunnelCenter(z + dz), z + dz);\n  vec3 fwd = normalize(axisAhead - ro);\n  vec3 rgt = normalize(cross(vec3(0.0, 1.0, 0.0), fwd));\n  vec3 upv = cross(fwd, rgt);\n\n  // gentle camera roll for life\n  vec2 ruv = rot(sin(t * 0.3) * 0.25) * uv;\n  vec3 rd = normalize(fwd * 1.5 + rgt * ruv.x + upv * ruv.y);\n\n  // ---- raymarch (constant loop bound) ----\n  float dist = 0.0;\n  float glowAcc = 0.0;     // volumetric haze accumulated along the ray\n  float coreAcc = 0.0;     // glow from the bright filament on the axis\n  float hit = -1.0;\n  vec3 pos = ro;\n  for (int i = 0; i < 96; i++){\n    pos = ro + rd * dist;\n    float d = mapScene(pos);\n\n    // bright filament running down the tunnel axis (analytic glow, not geometry):\n    // distance from this sample to the local axis -> inverse-square-ish falloff.\n    vec2 toAxis = pos.xy - tunnelCenter(pos.z);\n    float ra = length(toAxis);\n    coreAcc += (0.012 / (0.10 + ra * ra)) * 0.10;\n\n    // soft volumetric haze hugging the wall surface\n    glowAcc += exp(-9.0 * abs(d)) * 0.025;\n\n    if (d < 0.001){ hit = dist; break; }\n    dist += max(d, 0.02) * 0.6;   // conservative step; map is not a strict SDF\n    if (dist > 55.0) break;\n  }\n\n  vec3 glowCol = glow.rgb;\n  vec3 col = vec3(0.0);\n\n  if (hit > 0.0){\n    // surface normal via central differences (no dFdx)\n    vec2 e = vec2(0.0015, 0.0);\n    vec3 n = normalize(vec3(\n      mapScene(pos + e.xyy) - mapScene(pos - e.xyy),\n      mapScene(pos + e.yxy) - mapScene(pos - e.yxy),\n      mapScene(pos + e.yyx) - mapScene(pos - e.yyx)\n    ));\n\n    vec2 toAxis = pos.xy - tunnelCenter(pos.z);\n    float ang = atan(toAxis.y, toAxis.x);\n\n    // key light grazes the wall from down the tunnel: near walls fall into shadow,\n    // the ring crests ahead catch the light -> high-contrast depth, not a flat wash.\n    vec3 keyDir = normalize(fwd + vec3(-toAxis * 0.2, 0.0));\n    float diff = clamp(dot(n, keyDir), 0.0, 1.0);\n    diff = pow(diff, 1.6);                       // tighten the lit band\n\n    // fresnel rim picks out the facet edges\n    float fres = pow(1.0 - clamp(dot(n, -rd), 0.0, 1.0), 3.0);\n\n    // emissive bands sweeping along the wall -> reads as forward motion\n    float band = 0.5 + 0.5 * sin(pos.z * 5.0 - t * 7.0 + ang * 2.0);\n    band = band * band;                          // sharpen the stripes\n\n    // saturated palette: deep teal in shadow, electric cyan-white on the crests\n    vec3 deep = glowCol * vec3(0.10, 0.14, 0.20);\n    vec3 lit  = mix(glowCol, vec3(0.85, 0.97, 1.0), 0.45);\n    col  = mix(deep, lit, diff);\n    col += glowCol * fres * 1.1;                 // rim light on the facets\n    col += mix(glowCol, vec3(1.0), 0.4) * band * 0.35;\n\n    // atmospheric depth fade -> throat recedes into darkness\n    float fog = exp(-hit * 0.11);\n    col = mix(vec3(0.004, 0.01, 0.02), col, fog);\n  } else {\n    // looking straight down the open throat -> near-black for depth\n    col = vec3(0.004, 0.01, 0.02);\n  }\n\n  // composite the additive glows (core filament + thin haze)\n  col += glowCol * min(coreAcc, 1.0) * 0.55;\n  col += glowCol * glowAcc * 0.55;\n\n  // vignette to push depth toward the center\n  float vig = 1.0 - 0.32 * dot(uv, uv);\n  col *= vig;\n\n  // filmic-ish tonemap + gamma (no fancy builtins)\n  col = col / (1.0 + col);\n  col = pow(col, vec3(0.4545));\n\n  gl_FragColor = vec4(col, 1.0);\n}\n"
  }
}