subdivision-edge.compute 770 Bytes
Newer Older
1
#version 430 core
Philipp Adolf committed
2

3
layout  (local_size_x  =  1)  in;
4

5 6 7 8
struct Vertex {
    vec3 pos;
    vec3 norm;
    vec2 uv;
9 10
};

11 12 13 14 15 16 17 18 19
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 {
20
    Vertex edges[];
21 22 23
};

void main(){
24 25 26 27
    edges[gl_GlobalInvocationID.x].norm = vec3(0.0, 0.0, 0.0);
    edges[gl_GlobalInvocationID.x].uv = vec2(0.0, 0.0);

    edges[gl_GlobalInvocationID.x].pos = 3.0/8.0 * (vertices[indices[gl_GlobalInvocationID.x][0]].pos + vertices[indices[gl_GlobalInvocationID.x][1]].pos) + 1.0/8.0 * (vertices[indices[gl_GlobalInvocationID.x][2]].pos + vertices[indices[gl_GlobalInvocationID.y][3]].pos);
Philipp Adolf committed
28
}