-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathhex2.frag
More file actions
executable file
·62 lines (38 loc) · 1.22 KB
/
hex2.frag
File metadata and controls
executable file
·62 lines (38 loc) · 1.22 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
58
59
60
61
62
float hexDistance(vec2 uv) {
uv = abs(uv);
return max(uv.x, dot(uv, normalize(vec2(1., 1.73))));
}
vec4 hexCoords(vec2 uv) {
vec2 gv;
vec2 r = vec2(1., 1.73);
vec2 h = r * .5;
vec2 a = mod(uv, r) - h;
vec2 b = mod(uv - h, r) - h;
if (length(a) < length(b)) {
gv = a;
} else {
gv = b;
}
vec2 id = uv - gv;
float x = 0.;
float y = .5 - hexDistance(gv);
return vec4(x, y, id);
}
void mainImage(out vec4 fragColor, in vec2 fragCoords) {
vec2 uv = fragCoords.xy / iResolution.xy;
uv -= .5;
uv.x *= iResolution.x / iResolution.y;
vec3 col = vec3(0.);
uv *= 10.;
vec4 hex = hexCoords(uv);
col.rg = hex.zw / 2.;
col.b = pow(.03/hex.y, 1.1);
// float d = hexDistance(uv);
// col += step(d, .2);
// col += pow(.2/smoothstep(.0, .3, d), 1.3) * abs(sin(vec3(0.9, .3, .1) + iTime));
// col += .2/((1. - step(d, 0.2))*smoothstep(0., .6, d)) * vec3(0.9, .3, .1);
// float a = 3.14/4. + iTime;
// float d1 = hexDistance(uv * mat2(vec2(sin(a), cos(a)), vec2(-cos(a), sin(a))));
// col = col * .75 + pow(.2/smoothstep(.0, .3, d1), 1.3) * abs(sin(vec3(0.1, .9, .8) + iTime)) * .25;
fragColor = vec4(col, 1.);
}