| 1 |
// from https://www.shadertoy.com/view/4dBXRt |
| 2 |
|
| 3 |
const float thresh = 2.0; |
| 4 |
const float lowThresh = 0.25; |
| 5 |
|
| 6 |
// effect ringblobs |
| 7 |
// Just tried to recreate an effect I did years ago in Quickbasic. |
| 8 |
|
| 9 |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) { |
| 10 |
|
| 11 |
vec2 p = ( fragCoord.xy / iResolution.x ) - vec2(0.5, 0.5 * (iResolution.y / iResolution.x)); |
| 12 |
float time = iTime; |
| 13 |
|
| 14 |
vec3 rgb = vec3(0.0); |
| 15 |
float c = 0.0; |
| 16 |
for (int i=0; i<16; i++) |
| 17 |
{ |
| 18 |
vec2 pos = p + vec2(sin(float(i*i) + 0.5 * time) * 0.4, sin(float(i*i*i) + 0.7 * time) * 0.2); |
| 19 |
c += pow(0.08 / length(pos), 8.0); |
| 20 |
} |
| 21 |
if (c > 1.0 && c < thresh) c = (thresh - c) / (thresh - 1.0); |
| 22 |
if (c >= thresh) |
| 23 |
{ |
| 24 |
// do effect |
| 25 |
c = mod(sin(p.x * 80.0) + sin(p.y * 50.0) + sin(p.x * 16.0 + sin(p.y * 32.0 + 4.0 * time)) + sin(p.y * 24.0 + 3.0 * time + sin(p.x * 56.0 + p.y * 48.0)) + 4.0, 2.0); |
| 26 |
if (c > 1.0) c = 2.0 - c; |
| 27 |
rgb = vec3(c, c * 2.0, c * 4.0); |
| 28 |
} |
| 29 |
else if (c > lowThresh) |
| 30 |
{ |
| 31 |
rgb = vec3(c); |
| 32 |
} |
| 33 |
else |
| 34 |
{ |
| 35 |
float gr = p.x + p.y; |
| 36 |
float rx = floor(sin(gr * 15.0) + sin(gr * 25.0 - 3.0 * time) * 4.0); |
| 37 |
float ry = floor(sin(gr * 25.0 + time) + sin(gr * 35.0 + 4.0 * time) * 4.0); |
| 38 |
float rz = floor(sin(gr * 45.0) + sin(gr * 20.0 + sin(gr * 30.0 + 2.0 * time)) * 4.0); |
| 39 |
vec3 raster = vec3(rx, ry, rz) * 0.25; |
| 40 |
float d = c / lowThresh; |
| 41 |
rgb = d * vec3(c) + (1.0 - d) * raster; |
| 42 |
} |
| 43 |
|
| 44 |
fragColor = vec4(rgb, 1.0); |
| 45 |
|
| 46 |
} |