This repository was archived by the owner on Nov 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjulia.frag
More file actions
57 lines (42 loc) · 1.23 KB
/
julia.frag
File metadata and controls
57 lines (42 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
precision highp float;
#pragma glslify: ease = require(glsl-easings/bounce-in-out)
uniform vec2 uResolution;
uniform float uTime;
const int i_max = 2055;
// const vec2 i_const = vec2( -0.028, -0.61);
float er2 = 4.0; // er= er*er escape radius
vec2 complex_square( vec2 v ) {
return vec2(
v.x * v.x - v.y * v.y,
v.x * v.y * 2.0
);
}
void main() {
// compute coordinate
vec2 coord = gl_FragCoord.xy - uResolution * 0.5;
coord *= 2.5 / min( uResolution.x, uResolution.y );
float c_x_min = -0.0201;
float c_x_max = -0.0280;
float c_y_min = -0.6100;
float c_y_max = 0.74486;
float c_y = mix(c_y_min, c_y_max, abs(sin(uTime)+0.1));
float c_x = smoothstep(c_x_min, c_x_max, abs(cos(uTime)+0.1));
vec2 fractalConstant = vec2(c_x, c_y);
// float scale = 0.001;
float scale = 1./2000.;
int count = 0;
// iterations
for ( int i = 0 ; i < i_max; i++ ) {
coord = fractalConstant + complex_square( coord );
count = i;
if ( dot(coord,coord) > er2 ) { break; }
}
gl_FragColor=vec4(0.0,1.0,0.0,1.0);
if (count == i_max-1) {
// filled-in Julia set = red
// gl_FragColor = vec4(float( count ) * scale, 0.0,0.0,1.0);
} else {
// exterior
// gl_FragColor = vec4(1.0- float( count ) * scale );
}
}