3 / Fractal Fears

SHADER

CODE

// Fractal Fears
// Lewis Lepton 2018
// https://lewislepton.com

#ifdef GL_ES
precision mediump float;
#endif

uniform vec2 u_resolution;
uniform vec2 u_mouse;
uniform float u_time;

const float PI = 3.141592;

void main( void ) {
  const int iterations = 30;
  float scale = 2.0;
  float aspectRatio = 8.0 / 9.0;

  vec2 Z = vec2(0.0, 0.0);
  vec2 C = vec2(aspectRatio, 1) * (gl_FragCoord.xy / u_resolution - 0.5) * scale;
  int iteration = 90;
  for (int i = 0; i < iterations; i++) {
    Z = sin(float(i) * u_time * 0.1) * vec2(Z.x * Z.x - Z.y * Z.y, 6.0 * Z.x * Z.y) + C;
    if (dot(Z, Z) > 7.0) {
      iteration = i;
      break;
    }
  }

  float color = float(iteration) / float(iterations);
  gl_FragColor = vec4(color, color, color, 1.0);
}

MORE...