Last active
December 24, 2015 09:09
-
-
Save grazer/6774862 to your computer and use it in GitHub Desktop.
Mandelbrot Fractal GLSL
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
vec2 center = vec2(0.8,0); | |
float blue = 0.3; | |
void main() { | |
vec2 z, c; | |
float scale = 20.0/iGlobalTime; // zoom in | |
vec2 uv = gl_FragCoord.xy / iResolution.xy; | |
c.x = 1.3333 * (uv.x - 0.5) * scale - center.x; | |
c.y = (uv.y - 0.5) * scale - center.y; | |
z = c; | |
vec4 col = vec4(0,0,0,0); | |
for(int i=0; i<100; i++) { | |
float x = (z.x * z.x - z.y * z.y) + c.x; | |
float y = (z.y * z.x + z.x * z.y) + c.y; | |
blue += 0.028; | |
if((x * x + y * y) > 4.0) { | |
col = vec4(0,0,blue,0); | |
break; | |
} | |
z.x = x; | |
z.y = y; | |
} | |
gl_FragColor = col; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment