-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdat_glsl1_pixel__td_46224_2.frag
More file actions
97 lines (73 loc) · 2.62 KB
/
dat_glsl1_pixel__td_46224_2.frag
File metadata and controls
97 lines (73 loc) · 2.62 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
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
// from https://www.shadertoy.com/view/lsXSDn
uniform sampler2D sColors;
uniform float iTime;
in vec3 vUV;
out vec4 fragColor;
#define RAIN_SPEED 1.75 // Speed of rain droplets
#define DROP_SIZE 3.0 // Higher value lowers, the size of individual droplets
float rand(vec2 co){
return fract(sin(dot(co.xy ,vec2(12.9898,78.233))) * 43758.5453);
}
float rchar(vec2 outer, vec2 inner, float globalTime) {
//return float(rand(floor(inner * 2.0) + outer) > 0.9);
vec2 seed = floor(inner * 4.0) + outer.y;
if (rand(vec2(outer.y, 23.0)) > 0.98) {
seed += floor((globalTime + rand(vec2(outer.y, 49.0))) * 3.0);
}
return float(rand(seed) > 0.5);
}
void main() {
TDCheckDiscard();
vec2 position = vUV.xy;// / iResolution.xy;// .rgba .xyzw .stuv
vec2 uv = vec2(position.x, position.y);
//position.x /= iResolution.x / iResolution.y;
float globalTime = iTime * RAIN_SPEED;
float scaledown = DROP_SIZE;
float rx = vUV.x / (40.0 * scaledown);
float mx = 40.0*scaledown*fract(position.x * 30.0 * scaledown);
vec4 result;
if (mx > 12.0 * scaledown) {
result = vec4(0.0);
} else
{
float x = floor(rx);
float r1x = floor(vUV.x / (15.0));
float ry = position.y*600.0 + rand(vec2(x, x * 3.0)) * 100000.0 + globalTime* rand(vec2(r1x, 23.0)) * 120.0;
float my = mod(ry, 15.0);
if (my > 12.0 * scaledown) {
result = vec4(0.0);
} else {
float y = floor(ry / 15.0);
float b = rchar(vec2(rx, floor((ry) / 15.0)), vec2(mx, my) / 12.0, globalTime);
float col = max(mod(-y, 24.0) - 4.0, 0.0) / 20.0;
vec3 c = col < 0.8 ? vec3(0.0, col / 0.8, 0.0) : mix(vec3(0.0, 1.0, 0.0), vec3(1.0), (col - 0.8) / 0.2);
result = vec4(c * b, 1.0) ;
}
}
position.x += 0.05;
scaledown = DROP_SIZE;
rx = vUV.x / (40.0 * scaledown);
mx = 40.0*scaledown*fract(position.x * 30.0 * scaledown);
if (mx > 12.0 * scaledown) {
result += vec4(0.0);
} else
{
float x = floor(rx);
float r1x = floor(vUV.x / (12.0));
float ry = position.y*700.0 + rand(vec2(x, x * 3.0)) * 100000.0 + globalTime* rand(vec2(r1x, 23.0)) * 120.0;
float my = mod(ry, 15.0);
if (my > 12.0 * scaledown) {
result += vec4(0.0);
} else {
float y = floor(ry / 15.0);
float b = rchar(vec2(rx, floor((ry) / 15.0)), vec2(mx, my) / 12.0, globalTime);
float col = max(mod(-y, 24.0) - 4.0, 0.0) / 20.0;
vec3 c = col < 0.8 ? vec3(0.0, col / 0.8, 0.0) : mix(vec3(0.0, 1.0, 0.0), vec3(1.0), (col - 0.8) / 0.2);
result += vec4(c * b, 1.0) ;
}
}
result = result * length(texture(sColors,uv).rgb) + 0.22 * vec4(0.,texture(sColors,uv).g,0.,1.);
if(result.b < 0.5)
result.b = result.g * 0.5 ;
fragColor = result;
}