Last active
April 11, 2024 07:34
-
-
Save Hri7566/51688e25e5bedfdf7a27bd7572bd8d9b to your computer and use it in GitHub Desktop.
This file contains 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
float flimit(float n, float low, float high) | |
{ | |
return max(min(n, high), low); | |
} | |
float fmap(float n, float start1, float stop1, float start2, float stop2) | |
{ | |
float newval = (n - start1) / (stop1 - start1) * (stop2 - start2) + start2; | |
if (start2 < stop2) | |
{ | |
return flimit(newval, start2, stop2); | |
} | |
else | |
{ | |
return flimit(newval, stop2, start2); | |
} | |
} | |
vec3 hsl2rgb( in vec3 c ) | |
{ | |
vec3 rgb = clamp( abs(mod(c.x*6.0+vec3(0.0,4.0,2.0),6.0)-3.0)-1.0, 0.0, 1.0 ); | |
return c.z + c.y * (rgb-0.5)*(1.0-abs(2.0*c.z-1.0)); | |
} | |
float deg2rad(float deg) | |
{ | |
return deg * 0.01745329; | |
} | |
void mainImage( out vec4 fragColor, in vec2 fragCoord ) | |
{ | |
vec2 uv = fragCoord/iResolution.xy; | |
float x = fragCoord.x; | |
float y = fragCoord.y; | |
float time = 80.0; | |
float now = abs(sin(iTime / 50.0) * 10.0) - 50.0; | |
// float now = iTime; | |
// if (now == round(now)) now += 0.25; | |
float iter = ((now * now) * 6.0); | |
float size = fmap(now, 0.0, time, 4.0, 4.0 + time * now) * (now * now * now); | |
vec2 offset = vec2(0.23988, 0.510446); | |
float a = fmap(x, 0.0, iResolution.x, -8.0 / size, 8.0 / size) + offset.x; | |
float b = fmap(y, 0.0, iResolution.y, -4.5 / size, 4.5 / size) + offset.y; | |
float n = 0.0; | |
float ca = a; | |
float cb = b; | |
float z = 0.0; | |
while (n < iter) | |
{ | |
float aa = a * a - b * b; | |
float bb = 2.0 * a * b; | |
a = aa + ca; | |
b = bb + cb; | |
if (abs(a + b) > 16.0) | |
{ | |
break; | |
} | |
n++; | |
} | |
float hue = sqrt(size / n) * 10.0; | |
float bright = sqrt(fmap(n, 0.0, iter, 0.25, 0.75)); | |
float sat = sqrt(fmap(now, 0.0, now, 0.75, 1.0)); | |
if (n == iter) | |
{ | |
bright = 0.0; | |
} | |
// if (bright >= 0.72) bright = 0.0; | |
vec3 col = hsl2rgb(vec3(deg2rad(hue), sat, bright)); | |
fragColor = vec4(col, 1.0); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment