| #version 310 es | |
| struct Particle { | |
| vec2 pos; | |
| vec2 vel; | |
| }; | |
| struct Particles { | |
| Particle particles[5]; | |
| }; | |
| layout(binding = 0, std140) | |
| uniform params_block_1_ubo { | |
| uvec4 inner[2]; | |
| } v; | |
| layout(binding = 1, std430) | |
| buffer particlesA_block_1_ssbo { | |
| Particles inner; | |
| } v_1; | |
| layout(binding = 2, std430) | |
| buffer particlesB_block_1_ssbo { | |
| Particles inner; | |
| } v_2; | |
| void comp_main_inner(uvec3 v_3) { | |
| uint index = v_3.x; | |
| if ((index >= 5u)) { | |
| return; | |
| } | |
| uint v_4 = min(index, 4u); | |
| vec2 vPos = v_1.inner.particles[v_4].pos; | |
| uint v_5 = min(index, 4u); | |
| vec2 vVel = v_1.inner.particles[v_5].vel; | |
| vec2 cMass = vec2(0.0f); | |
| vec2 cVel = vec2(0.0f); | |
| vec2 colVel = vec2(0.0f); | |
| int cMassCount = 0; | |
| int cVelCount = 0; | |
| vec2 pos = vec2(0.0f); | |
| vec2 vel = vec2(0.0f); | |
| { | |
| uint i = 0u; | |
| while(true) { | |
| if ((i < 5u)) { | |
| } else { | |
| break; | |
| } | |
| if ((i == index)) { | |
| { | |
| i = (i + 1u); | |
| } | |
| continue; | |
| } | |
| uint v_6 = i; | |
| pos = v_1.inner.particles[v_6].pos.xy; | |
| uint v_7 = i; | |
| vel = v_1.inner.particles[v_7].vel.xy; | |
| uvec4 v_8 = v.inner[0u]; | |
| if ((distance(pos, vPos) < uintBitsToFloat(v_8.y))) { | |
| cMass = (cMass + pos); | |
| cMassCount = int((uint(cMassCount) + 1u)); | |
| } | |
| uvec4 v_9 = v.inner[0u]; | |
| if ((distance(pos, vPos) < uintBitsToFloat(v_9.z))) { | |
| colVel = (colVel - (pos - vPos)); | |
| } | |
| uvec4 v_10 = v.inner[0u]; | |
| if ((distance(pos, vPos) < uintBitsToFloat(v_10.w))) { | |
| cVel = (cVel + vel); | |
| cVelCount = int((uint(cVelCount) + 1u)); | |
| } | |
| { | |
| i = (i + 1u); | |
| } | |
| } | |
| } | |
| if ((cMassCount > 0)) { | |
| vec2 v_11 = cMass; | |
| float v_12 = float(cMassCount); | |
| vec2 v_13 = (v_11 / vec2(v_12, float(cMassCount))); | |
| cMass = (v_13 - vPos); | |
| } | |
| if ((cVelCount > 0)) { | |
| vec2 v_14 = cVel; | |
| float v_15 = float(cVelCount); | |
| cVel = (v_14 / vec2(v_15, float(cVelCount))); | |
| } | |
| uvec4 v_16 = v.inner[1u]; | |
| uvec4 v_17 = v.inner[1u]; | |
| uvec4 v_18 = v.inner[1u]; | |
| vVel = (((vVel + (cMass * uintBitsToFloat(v_16.x))) + (colVel * uintBitsToFloat(v_17.y))) + (cVel * uintBitsToFloat(v_18.z))); | |
| vVel = (normalize(vVel) * clamp(length(vVel), 0.0f, 0.10000000149011611938f)); | |
| uvec4 v_19 = v.inner[0u]; | |
| vPos = (vPos + (vVel * uintBitsToFloat(v_19.x))); | |
| if ((vPos.x < -1.0f)) { | |
| vPos.x = 1.0f; | |
| } | |
| if ((vPos.x > 1.0f)) { | |
| vPos.x = -1.0f; | |
| } | |
| if ((vPos.y < -1.0f)) { | |
| vPos.y = 1.0f; | |
| } | |
| if ((vPos.y > 1.0f)) { | |
| vPos.y = -1.0f; | |
| } | |
| uint v_20 = min(index, 4u); | |
| v_2.inner.particles[v_20].pos = vPos; | |
| uint v_21 = min(index, 4u); | |
| v_2.inner.particles[v_21].vel = vVel; | |
| } | |
| layout(local_size_x = 1, local_size_y = 1, local_size_z = 1) in; | |
| void main() { | |
| comp_main_inner(gl_GlobalInvocationID); | |
| } |