fractorb
view mbrot.glsl @ 0:6e849d7377ff
initial commit
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Sat, 18 Nov 2017 20:04:16 +0200 |
parents | |
children | 436f82447c44 |
line source
1 // vi:ft=glsl:
2 #define ITER 96
4 uniform float view_scale;
5 uniform vec2 view_center;
7 float mbrot_dist_point(in vec2 c, in vec2 p)
8 {
9 vec2 z = c;
10 float mindist_sq = 8192.0;
12 for(int i=0; i<ITER; i++) {
13 float x = (z.x * z.x - z.y * z.y) + c.x;
14 float y = (z.x * z.y + z.x * z.y) + c.y;
16 z = vec2(x, y);
17 mindist_sq = min(mindist_sq, dot(z, z));
18 }
20 return sqrt(mindist_sq);
21 }
23 void main()
24 {
25 vec2 c = gl_TexCoord[0].xy * view_scale - view_center;
26 float m = 1.0 - mbrot_dist_point(c, vec2(0.0, 0.0));
28 gl_FragColor.rgb = vec3(m, m, m);
29 gl_FragColor.a = 1.0;
30 }