Skip to content

Instantly share code, notes, and snippets.

@JPBotelho
Created December 28, 2018 12:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JPBotelho/73cdad5e20fda536c9f81c67de412b53 to your computer and use it in GitHub Desktop.
Save JPBotelho/73cdad5e20fda536c9f81c67de412b53 to your computer and use it in GitHub Desktop.
//Based on explanation http://www.hiddendimension.com/fractalmath/Divergent_Fractals_Main.html
void mainImage( out vec4 fragColor, in vec2 fragCoord )
{
vec2 c = fragCoord.xy / iResolution.xy;
//scaling real axis to [-2.5, 1.5] and imaginary axis to [-1.5, 1.5]
c = c * vec2(4,3) - vec2(2.5, 1.5);
vec2 z = vec2(0);
fragColor = vec4(0);
for (int i=0;i<100;i++)
{
if (z.x * z.x + z.y * z.y >= 4.)
{
fragColor = vec4(1);
break;
}
z = vec2(z.x*z.x - z.y*z.y, -2.*z.x*z.y);
z = z - vec2(z.x + abs(z.x), 0) - c;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment