-
Notifications
You must be signed in to change notification settings - Fork 0
/
shader.glsl
93 lines (73 loc) · 2.71 KB
/
shader.glsl
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
precision mediump float;
varying vec2 a_pos;
uniform float iTime;
uniform vec3 iGyro;
uniform vec2 iMouse;
uniform vec2 iResolution;
uniform float iAlpha;
uniform float iBeta;
uniform float iGamma;
// Fork of "magic curtain 3" by vivavolt. https://shadertoy.com/view/dslXzf
// 2022-11-25 04:51:03
#define alpha iAlpha
#define beta iBeta
#define gamma iGamma
#define t (iTime / 5. + 2.*alpha + 3.)
mat2 move(in float a) {
float c = cos(a);
float s = sin(a);
return mat2(c, -s, s, -c);
}
float temper(float x) {
return 0.5 + (x - 0.5) / 2.;
}
float map(in vec3 st) {
st.xy *= move(t * (0.2 + 0.2 * alpha));
st.xz *= move(t * (0.2 + 0.2 * beta));
vec3 p = st * (.2*sin(t / 10. * alpha) + 8. + 3.*beta) * 2.0 + t;
return length(st + vec3(sin(cos(t * 0.5 * gamma)))) + sin(p.x + sin(cos(p.y)* temper(iMouse.x + abs(iGyro.x)) + cos(p.z)*gamma* temper(iMouse.y + abs(iGyro.y)))) * 0.5 - 2.0;
}
float vignette(vec2 uv) {
uv *= 1.0 - uv.yx; //vec2(1.0)- uv.yx; -> 1.-u.yx; Thanks FabriceNeyret !
float vig = uv.x*uv.y * 15.0; // multiply with sth for intensity
vig = pow(vig, 0.25); // change pow for modifying the extend of the vignette
return vig;
}
vec3 pixel(vec2 p) {
vec2 st = p / iResolution.xy - vec2(1.0, 0.5);
vec3 col = vec3(beta, gamma, alpha);
float dist = 2.5;
for (int i = 0; i <= 3; i++) {
vec3 st = vec3(0.0, 0.0, beta) + normalize(vec3(st, -1.0)) * dist;
float rz = map(st);
float f = clamp((rz - map(st + 0.1)) * 0.5, -0.5, 1.0);
vec3 l = vec3(gamma*alpha, alpha*beta, beta*gamma) + vec3(3.+1.*sin(iTime / 5.), 2.5, 2.5) * f;
col = col * l + smoothstep(5.0, 2.0, rz) * 0.4 * l;
dist += min(rz, t);
}
return col;
}
vec3 blur9(vec2 p, vec2 resolution, vec2 direction) {
vec3 color = vec3(0.0);
vec2 off1 = vec2(1.3846153846) * direction;
vec2 off2 = vec2(3.2307692308) * direction;
color += pixel(p) * 0.2270270270;
color += pixel(p + (off1 / resolution)) * 0.3162162162;
color += pixel(p - (off1 / resolution)) * 0.3162162162;
color += pixel(p + (off2 / resolution)) * 0.0702702703;
color += pixel(p - (off2 / resolution)) * 0.0702702703;
return color;
}
void mainImage(out vec4 fragColor, in vec2 fragCoord) {
vec3 col = blur9(fragCoord.xy - iMouse.xy * 32. - iGyro.xy * 64., iResolution.xy, vec2(255., 255.));
fragColor = vec4(col,1.0);
vec2 uv = .5*(fragCoord.xy / iResolution.xy) + 0.5;
float vig = vignette(uv);
vec3 mixed = col.xyz;
fragColor = vec4(mixed, 1.0);
fragColor = mix(fragColor, vec4(vec3(0.), 1.), 1.-vig);
}
void main(void) {
mainImage(gl_FragColor, a_pos * iResolution.xy);
//gl_FragColor = vec4(a_pos.x, a_pos.y, 0, 1.0);
}