mirror of
https://git.code.sf.net/p/quake/quakeforge
synced 2024-12-04 01:51:36 +00:00
57 lines
1.1 KiB
Text
57 lines
1.1 KiB
Text
|
#version 450
|
||
|
|
||
|
layout (local_size_x = 32, local_size_y = 32) in;
|
||
|
|
||
|
struct Particle {
|
||
|
vec4 pos;
|
||
|
vec4 vel;
|
||
|
vec4 color;
|
||
|
float tex;
|
||
|
float ramp;
|
||
|
float scale;
|
||
|
float live;
|
||
|
};
|
||
|
|
||
|
struct Parameters {
|
||
|
vec4 drag; // [dx, dy, dz, grav scale]
|
||
|
vec4 ramp; // [rate, max, alpha rate, scale rate]
|
||
|
};
|
||
|
|
||
|
layout(std140, set = 0, binding = 0) buffer ParticleStates {
|
||
|
Particle particles[];
|
||
|
};
|
||
|
|
||
|
layout(std140, set = 0, binding = 1) buffer ParticleParameters {
|
||
|
Parameters parameters[];
|
||
|
};
|
||
|
|
||
|
layout(std140, set = 0, binding = 2) buffer ParticleSystem {
|
||
|
uint particleCount;
|
||
|
};
|
||
|
|
||
|
layout (push_constant) uniform PushConstants {
|
||
|
vec4 gravity;
|
||
|
float dT;
|
||
|
};
|
||
|
|
||
|
void
|
||
|
main ()
|
||
|
{
|
||
|
uint ind = gl_GlobalInvocationID.x;
|
||
|
if (ind >= particleCount) {
|
||
|
return;
|
||
|
}
|
||
|
Particle part = particles[ind];
|
||
|
Parameters parm = parameters[ind];
|
||
|
|
||
|
part.pos += dT * part.vel;
|
||
|
part.vel += dT * (part.vel * parm.drag + gravity * parm.drag.w);
|
||
|
|
||
|
part.ramp += dT * parm.ramp.x;
|
||
|
part.scale += dT * parm.ramp.z;
|
||
|
part.color.a -= dT * parm.ramp.a;
|
||
|
part.live -= dT;
|
||
|
|
||
|
particles[ind] = part;
|
||
|
}
|