-
Notifications
You must be signed in to change notification settings - Fork 0
/
view2.frag
187 lines (104 loc) · 3.65 KB
/
view2.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
mat3 laplace = mat3(0, 1, 0,
1, -4, 1,
0, 1, 0) / 8.;
mat3 sobelX = mat3(-1, 0, 1,
-2, 0, 2,
-1, 0, 1) / 8.;
mat3 sobelY = mat3(-1, -2, -1,
0, 0, 0,
1, 2, 1) / 8.;
mat3 identity = mat3(1, 0, 0,
0, 1, 0,
0, 0, 1) / 8.;
vec3 read(vec2 p, sampler2D tex) {
return texture2D(tex, p).xyz;
}
vec3 conv(vec2 p, sampler2D tex, mat3 filter) {
vec3 l = vec3(0.);
for (int y=0; y<3; y++)
for (int x = 0; x < 3; x++) {
l += filter[x][y] * texture2D(tex, p + vec2(x - 1, y - 1) / resolution ).xyz ;
}
return l;
}
mat2 rot(float phi) {
return mat2(cos(phi), -sin(phi),
sin(phi), cos(phi));
}
float circle(vec2 p, float r) {
return length(p) - r;
}
void main () {
vec2 vuv = uvN() * 2. - 1.;
float grid = step(.5, step(.96, fract(uvN().x * 40.)));
grid += step(.5, step(.96, fract(uvN().y * 20.)));
float c0 = circle((uv() ) * vec2(1., 1.), .9);
float c1 = circle((uv() ) * vec2(1., 1.), .89);
float c2 = circle((uv() ) * vec2(1., 1.), .88);
vec3 color = vec3(0.);
// color = c2 > 0.? grid * purple: vec3(0.);
vec3 inside = vec3(0.);
float sound = texture2D(backbuffer, uvN()).z * .1;
vec2 uvp = uv() ;
float pixel_angle = atan(uvp.x ,uvp.y) + acos(-1.);
float pixel_distance = length(uvp* .6) ;
vec2 st = vec2(pixel_angle , pixel_distance);
vec2 sts = vec2(st.x / acos(-1.) / 2. , 1.03 - st.y );
sts.x -= .1;
sts.x = sin(sts.y * 20.);
sts.y -= .4;
sound += conv(sts, channel0, sobelY ).x *8.;
// sound *= (sts.y - .5) * 2.;
// color += sound;
// polar camera
vec2 stc = st;
stc.y *= 1.3;
stc.x /= acos(-1.) * 2.;
stc.y = .7 + sin(time) / 100. - stc.y ;
// stc.y *= sound > .1 ? 1.-sin(sound) : 1.;
inside = conv(stc, channel1, laplace).xyz * 103.;
inside *= sin(stc.x * acos(-1.));
inside.x *= stc.x * 2.;
inside.y *= (1.-stc.x );
// inside *= 10.;
// sound /= sts.y;
// sound = sts.y * red;
// sound = sts.y * white;
// inside += inside;
// inside *= cos(sound);
vec2 uvr = vec2(vuv);
// color = vuv.y * red;
float f = time ;
// f*=0.;
// float f = 0.1;
uvr = mat2(cos(f), -sin(f), sin(f), cos(f)) * uvr;
// float f *= sound.x;
float pi = acos(-1.);
uvr.x *= (2. + cos(f * 2. +pi/4.) / 4.);
uvr.x /= (1. - sin(f * 2. + pi / 4. ) / 4.);
uvr.x /= 4.;
// uvr.x *= (2. - cos(f * 2.) / 2.) ;
uvr.x += .5;
// uvr.y /= 2.; //+ cos(f * 2. - 3.14/4.);;
uvr.y *= (2. - cos(f * 2. +pi/4.) / 8. ) ;
uvr.y /= (1. + sin(f * 2. +pi/4. ) / 4.);
// uvr.y /= (1. + sin(f * 2.) / 2.);
uvr.y /= 2.;
// uvr.y /= 2.;
uvr.y += .5;
color = read(uvr, backbuffer) * 2.0* green;
vec3 sky = conv(uvr.xy, backbuffer, laplace) * 8. * purple ;
// sky += sound;
// color = black;
// inside *= sound;
inside += sky;
// color += sound * red * 10.;
// inside += sound * red;
color += c2 < sound ? inside : sky ;
// color = c2 < sound ? black : white;
// color = red;
// color = sound * purple;
// color = uvr.y * red;
// color = black;
gl_FragColor = vec4(color, sound);
}