|
|
|
#version 450
|
|
|
|
|
|
|
|
layout (local_size_x = 32) in;
|
|
|
|
|
|
|
|
struct Vertex {
|
|
|
|
vec3 position;
|
|
|
|
vec3 color;
|
|
|
|
vec3 normal;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Edge {
|
|
|
|
uint a;
|
|
|
|
uint b;
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
layout (std430, set = 0, binding = 0) buffer VertexBuffer {
|
|
|
|
Vertex vertices[];
|
|
|
|
};
|
|
|
|
|
|
|
|
layout (std430, set = 0, binding = 2) buffer EdgeBuffer {
|
|
|
|
Edge edges[];
|
|
|
|
};
|
|
|
|
|
|
|
|
layout (std140, set = 0, binding = 5) uniform Sizes {
|
|
|
|
uint vertexCount;
|
|
|
|
uint faceCount;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout (std140, set = 1, binding = 0) uniform UBO {
|
|
|
|
float dt;
|
|
|
|
vec3 gravity;
|
|
|
|
};
|
|
|
|
|
|
|
|
layout (push_constant) uniform PushConstants {
|
|
|
|
uint state;
|
|
|
|
int vertexOffset;
|
|
|
|
};
|
|
|
|
|
|
|
|
void preSolve(uint vID){
|
|
|
|
vertices[vID].position += vec3(0.0001, 0, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void postSolve(uint vID){
|
|
|
|
vertices[vID].position += vec3(0, 0.0001, 0);
|
|
|
|
}
|
|
|
|
|
|
|
|
void main() {
|
|
|
|
uint id = gl_GlobalInvocationID.x;
|
|
|
|
switch (state){
|
|
|
|
case 0:
|
|
|
|
if (id < vertexCount){
|
|
|
|
preSolve(id);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
if (id < vertexCount){
|
|
|
|
postSolve(id);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|