#version 300 es precision highp float; uniform vec3 iResolution; uniform float iTime; out vec4 FragColor; #define T (iTime) float orb(vec3 p) { // orb time float t = T * 4.f; return length(p - vec3(sin(sin(t * .2f) + t * .4f) * 6.f, 1.f + sin(sin(t * .5f) + t * .2f) * 4.f, 12.f + T + cos(t * .3f) * 8.f)); } void mainImage(out vec4 o, vec2 u) { float d, a, e, i, s, t = T; vec3 p = iResolution; // scale coords u = (u + u - p.xy) / p.y; // camera movement u += vec2(cos(t * .1f) * .3f, cos(t * .3f) * .1f); for(o *= i; i++ < 128.f; // accumulate distance d += s = min(.03f + .2f * abs(s), e = max(.5f * e, .01f)), // grayscale color and orb light o += 1.f / (s + e * 3.f)) // noise loop start, march for(p = vec3(u * d, d + t), // p = ro + rd *d, p.z + t; // entity (orb) e = orb(p) - .1f, // spin by t, twist by p.z p.xy *= mat2(cos(.1f * t + p.z / 8.f + vec4(0, 33, 11, 0))), // mirrored planes 4 units apart s = 4.f - abs(p.y), // noise starts at .8 up to 32., grow by a+=a a = .8f; a < 32.f; a += a) // apply turbulence p += cos(.7f * t + p.yzx) * .2f, // apply noise s -= abs(dot(sin(.1f * t + p * a), .6f + p - p)) / a; // tanh tonemap, brightness, light off-screen o = tanh(o / 1e1f); } void main() { mainImage(FragColor, gl_FragCoord.xy); }