-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglut_222.frag
53 lines (44 loc) · 1.36 KB
/
glut_222.frag
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
#ifdef GL_ES
precision mediump float;
#endif
#extension GL_ARB_explicit_uniform_location : enable
uniform vec2 iResolution;
uniform float iTime;
varying out vec4 aVertexColor;
//#define SHOW_TILING 1
#define TAU 6.28318530718
#define MAX_ITER 5
void main (void)
{
float time = iTime * .5+23.0;
// uv should be the 0-1 uv of texture...
vec2 uv = gl_FragCoord.xy / iResolution.xy;
#ifdef SHOW_TILING
vec2 p = mod(uv*TAU*2.0, TAU)-250.0;
#else
vec2 p = mod(uv*TAU, TAU)-250.0;
#endif
vec2 i = p;
float c = 1.0;
float inten = .005;
for (int n = 0; n < MAX_ITER; n++)
{
float t = time * (1.0 - (3.5 / float(n+1)));
i = p + vec2(cos(t - i.x) + sin(t + i.y), sin(t - i.y) + cos(t + i.x));
c += 1.0/length(vec2(p.x / (sin(i.x+t)/inten),p.y / (cos(i.y+t)/inten)));
}
c /= float(MAX_ITER);
c = 1.17-pow(c, 1.4);
vec3 colour = vec3(pow(abs(c), 8.0));
colour = clamp(colour + vec3(0.0, 0.35, 0.5), 0.0, 1.0);
#ifdef SHOW_TILING
// Flash tile borders...
vec2 pixel = 2.0 / iResolution.xy;
uv *= 2.0;
float f = floor(mod(iTime*.5, 2.0)); // Flash value.
vec2 first = step(pixel, uv) * f; // Rule out first screen pixels and flash.
uv = step(fract(uv), pixel); // Add one line of pixels per tile.
colour = mix(colour, vec3(1.0, 1.0, 0.0), (uv.x + uv.y) * first.x * first.y); // Yellow line
#endif
aVertexColor = vec4(colour, 1.0);
}