-
Notifications
You must be signed in to change notification settings - Fork 0
/
autowaves2
75 lines (50 loc) · 1.77 KB
/
autowaves2
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
63
64
65
66
67
68
69
70
71
72
73
74
75
vec4 read(vec2 p) {
return texture2D(backbuffer, p);
}
const mat3 gauss = mat3(1.0, 2.0, 1.0,
2.0,-12.0, 2.0,
1.0, 2.0, 1.0) / 8.0;
const mat3 idm = mat3(1., 0., 0.,
0., 1., 0.,
0., 0., 1.);
mat2 rot(float a) {
return mat2(cos(a), -sin(a),
sin(a), cos(a));
}
vec3 conv (ivec2 xy, mat3 filter, mat3 m) {
vec3 l = vec3(0.0);
filter *= m;
for (int y=0; y<3; ++y)
for (int x=0; x<3; ++x) {
ivec2 p = xy + ivec2(x-1, y-1);
vec4 v = read(vec2(p) / (resolution.xy - vec2(.5) ));
l += filter[x][y] * v.xyz;
}
return l;
}
float circle(vec2 p, float r) {
return length(p) - pow(r, 2.);
}
void main () {
vec2 data = ((mouse.xy / resolution.xy) - vec2(1.)) * vec2(2., 1.) ;
float rate_a = 1.;
float rate_b = .5;
float feed = 0.56 + uv().y / 10.;
float kill = 0.019 + uv().x / 10.;
float speed = 1.;
float paint = 1.;
vec4 val = read(uvN());
float a = val.x;
float b = val.z;
mat3 m = mat3(val.x, 0., 0.,
0., - val.x + val.z, 0.,
0., 0., val.x) *1.;
ivec2 coord = ivec2(gl_FragCoord.xy);
float da = rate_a * conv(coord, gauss, m ).x - a*b*b + conv(coord, gauss, idm).x * feed * (1.-a);
float db = rate_b * conv(coord, gauss, m).z + a*b*b - kill * b;
vec3 color = val.xyz + vec3(da, 0, db) * speed;
vec2 uvp = vec2(uv().x - data.x, -uv().y - (data.y) ) - vec2(.1);
color += paint * circle(uvp, .3 + sin(time * 6.) / 10.) < 0. ? vec3(sin(time), 0., 0.) : vec3(0.);
color += paint * circle(uvp, .3 + sin(time * 16.) / 60.) < 0. ? vec3(0., 0., sin(time*5.)) : vec3(0.);
gl_FragColor = vec4(color, 1.);
}