1#version 310 es
2precision mediump float;
3
4struct tint_symbol_2 {
5  vec2 a_particlePos;
6  vec2 a_particleVel;
7  vec2 a_pos;
8};
9struct tint_symbol_3 {
10  vec4 value;
11};
12
13vec4 vert_main_inner(vec2 a_particlePos, vec2 a_particleVel, vec2 a_pos) {
14  float angle = -(atan(a_particleVel.x, a_particleVel.y));
15  vec2 pos = vec2(((a_pos.x * cos(angle)) - (a_pos.y * sin(angle))), ((a_pos.x * sin(angle)) + (a_pos.y * cos(angle))));
16  return vec4((pos + a_particlePos), 0.0f, 1.0f);
17}
18
19struct tint_symbol_4 {
20  vec4 value;
21};
22struct Particle {
23  vec2 pos;
24  vec2 vel;
25};
26struct tint_symbol_6 {
27  uvec3 tint_symbol;
28};
29
30tint_symbol_3 vert_main(tint_symbol_2 tint_symbol_1) {
31  vec4 inner_result = vert_main_inner(tint_symbol_1.a_particlePos, tint_symbol_1.a_particleVel, tint_symbol_1.a_pos);
32  tint_symbol_3 wrapper_result = tint_symbol_3(vec4(0.0f, 0.0f, 0.0f, 0.0f));
33  wrapper_result.value = inner_result;
34  return wrapper_result;
35}
36in vec2 a_particlePos;
37in vec2 a_particleVel;
38in vec2 a_pos;
39void main() {
40  tint_symbol_2 inputs;
41  inputs.a_particlePos = a_particlePos;
42  inputs.a_particleVel = a_particleVel;
43  inputs.a_pos = a_pos;
44  tint_symbol_3 outputs;
45  outputs = vert_main(inputs);
46  gl_Position = outputs.value;
47  gl_Position.y = -gl_Position.y;
48}
49
50
51#version 310 es
52precision mediump float;
53
54struct tint_symbol_2 {
55  vec2 a_particlePos;
56  vec2 a_particleVel;
57  vec2 a_pos;
58};
59struct tint_symbol_3 {
60  vec4 value;
61};
62struct tint_symbol_4 {
63  vec4 value;
64};
65
66vec4 frag_main_inner() {
67  return vec4(1.0f, 1.0f, 1.0f, 1.0f);
68}
69
70struct Particle {
71  vec2 pos;
72  vec2 vel;
73};
74struct tint_symbol_6 {
75  uvec3 tint_symbol;
76};
77
78tint_symbol_4 frag_main() {
79  vec4 inner_result_1 = frag_main_inner();
80  tint_symbol_4 wrapper_result_1 = tint_symbol_4(vec4(0.0f, 0.0f, 0.0f, 0.0f));
81  wrapper_result_1.value = inner_result_1;
82  return wrapper_result_1;
83}
84out vec4 value;
85void main() {
86  tint_symbol_4 outputs;
87  outputs = frag_main();
88  value = outputs.value;
89}
90
91
92#version 310 es
93precision mediump float;
94
95struct tint_symbol_2 {
96  vec2 a_particlePos;
97  vec2 a_particleVel;
98  vec2 a_pos;
99};
100struct tint_symbol_3 {
101  vec4 value;
102};
103struct tint_symbol_4 {
104  vec4 value;
105};
106struct Particle {
107  vec2 pos;
108  vec2 vel;
109};
110
111layout (binding = 0) uniform SimParams_1 {
112  float deltaT;
113  float rule1Distance;
114  float rule2Distance;
115  float rule3Distance;
116  float rule1Scale;
117  float rule2Scale;
118  float rule3Scale;
119} params;
120layout (binding = 1) buffer Particles_1 {
121  Particle particles[5];
122} particlesA;
123layout (binding = 2) buffer Particles_2 {
124  Particle particles[5];
125} particlesB;
126
127struct tint_symbol_6 {
128  uvec3 tint_symbol;
129};
130
131void comp_main_inner(uvec3 tint_symbol) {
132  uint index = tint_symbol.x;
133  if ((index >= 5u)) {
134    return;
135  }
136  vec2 vPos = particlesA.particles[index].pos;
137  vec2 vVel = particlesA.particles[index].vel;
138  vec2 cMass = vec2(0.0f, 0.0f);
139  vec2 cVel = vec2(0.0f, 0.0f);
140  vec2 colVel = vec2(0.0f, 0.0f);
141  int cMassCount = 0;
142  int cVelCount = 0;
143  vec2 pos = vec2(0.0f, 0.0f);
144  vec2 vel = vec2(0.0f, 0.0f);
145  {
146    for(uint i = 0u; (i < 5u); i = (i + 1u)) {
147      if ((i == index)) {
148        continue;
149      }
150      pos = particlesA.particles[i].pos.xy;
151      vel = particlesA.particles[i].vel.xy;
152      if ((distance(pos, vPos) < params.rule1Distance)) {
153        cMass = (cMass + pos);
154        cMassCount = (cMassCount + 1);
155      }
156      if ((distance(pos, vPos) < params.rule2Distance)) {
157        colVel = (colVel - (pos - vPos));
158      }
159      if ((distance(pos, vPos) < params.rule3Distance)) {
160        cVel = (cVel + vel);
161        cVelCount = (cVelCount + 1);
162      }
163    }
164  }
165  if ((cMassCount > 0)) {
166    cMass = ((cMass / vec2(float(cMassCount), float(cMassCount))) - vPos);
167  }
168  if ((cVelCount > 0)) {
169    cVel = (cVel / vec2(float(cVelCount), float(cVelCount)));
170  }
171  vVel = (((vVel + (cMass * params.rule1Scale)) + (colVel * params.rule2Scale)) + (cVel * params.rule3Scale));
172  vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.100000001f));
173  vPos = (vPos + (vVel * params.deltaT));
174  if ((vPos.x < -1.0f)) {
175    vPos.x = 1.0f;
176  }
177  if ((vPos.x > 1.0f)) {
178    vPos.x = -1.0f;
179  }
180  if ((vPos.y < -1.0f)) {
181    vPos.y = 1.0f;
182  }
183  if ((vPos.y > 1.0f)) {
184    vPos.y = -1.0f;
185  }
186  particlesB.particles[index].pos = vPos;
187  particlesB.particles[index].vel = vVel;
188}
189
190layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in;
191void comp_main(tint_symbol_6 tint_symbol_5) {
192  comp_main_inner(tint_symbol_5.tint_symbol);
193  return;
194}
195void main() {
196  tint_symbol_6 inputs;
197  inputs.tint_symbol = gl_GlobalInvocationID;
198  comp_main(inputs);
199}
200
201
202