]> Witch of Git - lovr-particles/blob - shaders/particles.comp
6e136b42e84034162d3b508aae708d5e125b4339
[lovr-particles] / shaders / particles.comp
1 uniform float dt;
2
3 struct particle_t {
4 vec4 positionAndSize;
5 vec4 velocity;
6 vec4 padding2; // for LÖVR's limited ShaderBlock type :(
7 vec4 padding3; // for LÖVR's limited ShaderBlock type :(
8 };
9 layout(std430) buffer particleData {
10 float reloadFlag;
11 particle_t particles[];
12 };
13
14 layout(local_size_x = 128) in;
15 void compute() {
16 uint id = gl_GlobalInvocationID.x;
17 vec3 vel = particles[id].velocity.xyz;
18 particles[id].positionAndSize.xyz += vel * dt;
19 particles[id].velocity.xyz -= vel * length(vel) * dt;
20 }