Last active
December 21, 2020 18:29
-
-
Save Softwave/22f6b30e32c450d017386395c51c21e6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uniform float time; | |
uniform vec2 resolution; | |
uniform vec2 mouse; | |
uniform int iterations; | |
uniform float zoom = 0.1; | |
uniform float zoomPos1 = 0.755; | |
uniform float speedMod = 0.3; | |
vec2 complex_square(vec2 num) | |
{ | |
float real = num.x * num.x - num.y * num.y; | |
float imaginary = num.x * num.y * 2.0; | |
return vec2(real, imaginary); | |
} | |
vec3 hsv(float h, float s, float v) | |
{ | |
vec4 t = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0); | |
vec3 p = abs(fract(vec3(h) + t.xyz) * 6.0 - vec3(t.w)); | |
return v * mix(vec3(t.x), clamp(p - vec3(t.x), 0.0, 1.0), s); | |
} | |
void main() | |
{ | |
vec2 position = gl_FragCoord.xy / resolution.xy * 2.0 - 1.0; | |
vec2 z = vec2(sin(time * speedMod / 64.0), 0.0); | |
float zlen = 0.0; | |
vec2 c = position - 0.5; | |
float i = 0.0; | |
// Zoom | |
c.y *= -1.0; | |
c /= pow(1.5, zoom - 3.0); | |
c.y += 0.1; | |
c.x -= sqrt( zoomPos1 * zoomPos1 - 0.1 * 0.1 ); | |
for (int k = 0; k < iterations; k++) | |
{ | |
i++; | |
z = complex_square(z) + c; | |
zlen = sqrt(z.x * z.x + z.y * z.y); | |
if (zlen > 4.0) { | |
break; | |
} | |
} | |
vec3 color = vec3(i / float(iterations)); | |
vec3 col = sin(vec3(0.8, 0.25, 0.65) * color * 20.0) * 0.5 + 0.5; | |
float h = abs(mod(time * 15.0 - float(i), 50.0) / 660.0); | |
vec3 rgb = hsv(h, 1.0, 1.0); | |
gl_FragColor = vec4(rgb, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment