higher escape value, added smooth coloring with normalization

master
Benjamin Kraft 3 years ago
parent d054592840
commit fd230391d3
  1. 19
      Fragment.glsl

@ -42,23 +42,24 @@ vec2 m(in vec2 c){
return square(c) + complexPos; return square(c) + complexPos;
} }
int mandelbrot(in vec2 c){ float mandelbrot(in vec2 c){
vec2 z = vec2(0, 0); vec2 z = vec2(0, 0);
int steps = 0; float steps = 0;
while (steps < iterationCount && length(z) <= 2){ int escapeSquared = pow(1 << 8, 2);
while (steps < iterationCount && pow(z.x, 2) + pow(z.y, 2) < escapeSquared){
z = m(z); z = m(z);
++steps; ++steps;
} }
if (steps == iterationCount) if (steps == iterationCount)
return 0; return 0.;
return steps; float log_zn = log(z.x * z.x + z.y * z.y) / 2;
float nu = log(log_zn / log(2)) / log(2);
steps += 1 - nu;
return steps / iterationCount;
} }
void main(){ void main(){
float modifier = mandelbrot(complexPos);
int m = mandelbrot(complexPos);
float modifier = sqrt(float(m) / iterationCount);
pixColor = vec4(getColor(modifier), 1); pixColor = vec4(getColor(modifier), 1);
} }

Loading…
Cancel
Save