forked from goliath/shadermeh
27 lines
832 B
GLSL
27 lines
832 B
GLSL
|
#define MAX_ITERATIONS 1024
|
||
|
|
||
|
void mainImage(out vec4 fragColor, in vec2 fragCoord)
|
||
|
{
|
||
|
float s = exp(-iTime / 2.0);
|
||
|
vec2 c = vec2(-0.770007,0.100001);
|
||
|
vec2 z = vec2(0.0);
|
||
|
vec2 del = (2.0 * fragCoord/iResolution.xy - 1.0) * s;
|
||
|
del.x /= (iResolution.y / iResolution.x);
|
||
|
vec2 eps = vec2(0.0);
|
||
|
|
||
|
int iterations = 0;
|
||
|
while (length(z + eps) < 2.0 && iterations < MAX_ITERATIONS) {
|
||
|
eps = 2.0*vec2(z.x*eps.x - z.y*eps.y, z.x*eps.y + z.y*eps.x) + vec2(eps.x*eps.x - eps.y*eps.y, 2.0*eps.x*eps.y) + del;
|
||
|
z = vec2(z.x*z.x - z.y*z.y, 2.0*z.x*z.y) + c;
|
||
|
if (length(eps) > 100.0) {
|
||
|
z += eps;
|
||
|
eps = vec2(0.0);
|
||
|
}
|
||
|
iterations += 1;
|
||
|
}
|
||
|
|
||
|
|
||
|
// Output to screen
|
||
|
fragColor = vec4(vec3(float(iterations) / float(MAX_ITERATIONS)), 1.0);
|
||
|
}
|