fractorb

view mbrot.glsl @ 1:436f82447c44

pan/scale and min orbit distance from point drawing
author John Tsiombikas <nuclear@member.fsf.org>
date Sun, 19 Nov 2017 00:57:39 +0200
parents 6e849d7377ff
children f440ecffc45a
line source
1 // vi:ft=glsl:
2 #define ITER 96
4 uniform float view_scale;
5 uniform vec2 view_center;
6 uniform vec2 seed;
8 float mbrot_dist_point(in vec2 c, in vec2 p)
9 {
10 vec2 z = c;
11 float mindist_sq = 8192.0;
13 for(int i=0; i<ITER; i++) {
14 float x = (z.x * z.x - z.y * z.y) + c.x;
15 float y = (z.x * z.y + z.x * z.y) + c.y;
17 z = vec2(x, y);
18 vec2 dir = z - seed;
19 mindist_sq = min(mindist_sq, dot(dir, dir));
20 }
22 return sqrt(mindist_sq);
23 }
25 void main()
26 {
27 vec2 c = gl_TexCoord[0].xy;
28 float m = 1.0 - mbrot_dist_point(c, vec2(0.0, 0.0));
30 gl_FragColor.rgb = vec3(m, m, m);
31 gl_FragColor.a = 1.0;
32 }