30 lines
No EOL
486 B
Text
30 lines
No EOL
486 B
Text
#version 450
|
|
|
|
struct Particle
|
|
{
|
|
vec4 pos;
|
|
vec4 vel;
|
|
};
|
|
|
|
// Binding 0 : Position storage buffer
|
|
layout(std140, binding = 0) buffer Pos
|
|
{
|
|
Particle particles[ ];
|
|
};
|
|
|
|
layout (local_size_x = 256) in;
|
|
|
|
layout (binding = 1) uniform UBO
|
|
{
|
|
float deltaT;
|
|
int particleCount;
|
|
} ubo;
|
|
|
|
void main()
|
|
{
|
|
int index = int(gl_GlobalInvocationID);
|
|
vec4 position = particles[index].pos;
|
|
vec4 velocity = particles[index].vel;
|
|
position += ubo.deltaT * velocity;
|
|
particles[index].pos = position;
|
|
} |