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
|
#version 430
layout(local_size_x = 1, local_size_y = 1) in;
uniform float seconds = 0;
layout(rgba8) uniform readonly image2D noise_texture;
layout(rgba8) uniform readonly image2D subtexture;
layout(rgba8) uniform writeonly image2D output_image;
uniform float flow_field[400];
uniform vec2 particles[100];
uniform int particles_count;
float sample_noise(in vec2 p) {
vec4 noise = imageLoad(noise_texture, ivec2(p * imageSize(noise_texture)));
return noise.x;
}
float gen_pattern(in vec2 p, out vec3 coloring_factor, out vec3 coloring_factor2) {
float s1 = sample_noise(p + sample_noise(p) * vec2(0.5, 0.1));
float s2 = sample_noise(p + sample_noise(p) * vec2(0.8, 0.4));
float s3 = sample_noise(p + sample_noise(p));
coloring_factor = vec3(0.204, 0.11, 0.01) * vec3(s1 * s2, 0.3 * s3, 0.3 * s3);
coloring_factor2 = vec3(0.4, 0.3 * s3, 0.3 * s3);
return sample_noise(p + s2 * s1 * s3);
}
vec3 srgb(in float r, in float g, in float b) {
return vec3(pow(r, 2.2), pow(g, 2.2), pow(b, 2.2));
}
void main() {
vec2 uv = vec2(gl_GlobalInvocationID.xy) / imageSize(output_image).xy;
// vec3 coloring_factor;
// vec3 coloring_factor2;
// float v = gen_pattern(uv, coloring_factor, coloring_factor2);
// coloring_factor = srgb(0.941, 0.827, 0.706);
// coloring_factor2 = srgb(0.204, 0.11, 0.01);
// coloring_factor2 = srgb(0.204, 0.11, 0.01);
// coloring_factor2 = srgb(0.104, 0.06, 0.00);
// vec3 color = mix(coloring_factor, coloring_factor2, clamp(v, 0., 1.));
ivec2 grid = ivec2(20, 20);
vec2 p = uv * grid;
int ffidx = int(p.x) + int(p.y) * grid.y;
float cell = flow_field[ffidx];
// vec3 color = vec3(ffidx/400.);
vec3 color = vec3(cell);
// subtexture
for (int i = 0; i < particles_count; i++) {
vec2 p = particles[i];
if (length(uv - p) - 0.01 <= 0) {
color = vec3(1, 0, 0);
}
}
// color = imageLoad(noise_texture, ivec2(uv * imageSize(output_image).xy)).xyz;
imageStore(output_image, ivec2(gl_GlobalInvocationID.xy), vec4(color, 1));
}
|