heavenly wisp
Oct 12, 2025https://www.shadertoy.com/view/wXscRf #shadertoy
// Fork of "Phosphorus" by MJK123. https://shadertoy.com/view/W3lyRf
// 2025-10-09 01:41:16
/*------------------------------------------------------------
Gyroid / Volumetric Ring Shader with Edge Detection
------------------------------------------------------------
Edge detection added via gradient sampling to highlight
sharp transitions in the distance field.
------------------------------------------------------------*/
// Distance field function (extracted for edge detection)
float sdf(vec3 p, float t)
{
// Spatial scrambling
for (float j = 1.0; j < 7.0; j++) {
p += sin(1.1 * p * j + t).yzx / j;
}
// Gyroid-like pattern
float r = 2.0;
r *= 4.0 * dot(cos(p.xy), sin(p.zx / 3.0)) + 0.3;
// Distance field
return abs(length(p.xz) - r) + abs(mod(p.y, 2.0) - 1.0);
}
// Edge detection via gradient magnitude
float edgeDetect(vec3 p, float t, float epsilon)
{
float d = sdf(p, t);
// Sample in 6 directions
float dx = sdf(p + vec3(epsilon, 0, 0), t);
float dy = sdf(p + vec3(0, epsilon, 0), t);
float dz = sdf(p + vec3(0, 0, epsilon), t);
// Gradient magnitude = edge strength
vec3 grad = vec3(dx - d, dy - d, dz - d) / epsilon;
return length(grad);
}
void mainImage(out vec4 O, vec2 I)
{
vec3 col = vec3(0.0);
vec3 edgeCol = vec3(0.0);
vec2 uv = (2.0 * I - iResolution.xy) / iResolution.y;
float t = iTime / 16.0;
float z = 0.0;
float d;
for (float i = 0.0; i < 12.0; i++)
{
vec3 p = z * normalize(vec3(uv, 3.0));
p.z -= 5.0;
p.y -= t;
d = sdf(p, t);
// Edge detection
float edge = edgeDetect(p, t, 0.05);
edge = smoothstep(2.0, 8.0, edge); // Tune thresholds for edge sharpness
d *= 0.15;
// Base volumetric glow
col += vec3(0.427, 0.424, 0.675) / d * z;
// Edge highlight (cyan)
edgeCol += vec3(0.773,0.867,0.075) * edge / (d * 2.0) * z;
z += d;
}
// Mix base + edges
col = col + edgeCol * 0.8; // Tune 0.8 for edge intensity
O.rgb = tanh(col / .5e3);
O.a = 1.0;
}