#version 430 core
layout (local_size_x = 1) in;
struct Vertex {
vec3 pos;
vec3 norm;
vec2 uv;
};
layout(std430, binding=0) readonly buffer Vertices {
Vertex vertices[];
};
layout(std430, binding=1) readonly buffer EdgeIndices {
unsigned int indices[][4];
};
layout(std430, binding=2) writeonly buffer Output {
Vertex edges[];
};
void main(){
edges[gl_GlobalInvocationID.x].uv = vec2(0.0, 0.0);
Vertex a = vertices[indices[gl_GlobalInvocationID.x][0]];
Vertex b = vertices[indices[gl_GlobalInvocationID.x][1]];
Vertex c = vertices[indices[gl_GlobalInvocationID.x][2]];
Vertex d = vertices[indices[gl_GlobalInvocationID.x][3]];
vec3 pos;
edges[gl_GlobalInvocationID.x].pos = 3.0f/8.0f * a.pos + 3.0f/8.0f * b.pos + 1.0f/8.0f * c.pos + 1.0f/8.0f * d.pos;
edges[gl_GlobalInvocationID.x].norm = normalize(3.0f/8.0f * a.norm + 3.0f/8.0f * b.norm + 1.0f/8.0f * c.norm + 1.0f/8.0f * d.norm);
}