Commit cce97fe9 by Philipp Adolf

Finish vertex compute shader

parent 4f193052
......@@ -29,7 +29,6 @@ layout(std430, binding=3) writeonly buffer Output {
void main(){
unsigned int size = offsets[gl_GlobalInvocationID.x + 1] - offsets[gl_GlobalInvocationID.x];
new_vertices[gl_GlobalInvocationID.x].norm = vec3(0.0f, 0.0f, 0.0f);
new_vertices[gl_GlobalInvocationID.x].uv = vec2(0.0f, 0.0f);
// FIXME: size or size - 1?
......@@ -37,9 +36,12 @@ void main(){
float alpha = 5.0f/8.0f - t * t;
vec3 pos = vec3(0.0f, 0.0f, 0.0f);
vec3 norm = vec3(0.0f, 0.0f, 0.0f);
for (unsigned int i = 1; i < size; i++) {
pos += vertices[indices[offsets[gl_GlobalInvocationID.x] + i]].pos;
norm += vertices[indices[offsets[gl_GlobalInvocationID.x] + i]].norm;
}
new_vertices[gl_GlobalInvocationID.x].pos = (1.0f - alpha) * vertices[indices[offsets[gl_GlobalInvocationID.x]]].pos + alpha / (float(size) - 1) * pos;
new_vertices[gl_GlobalInvocationID.x].pos = (1.0f - alpha) * vertices[indices[offsets[gl_GlobalInvocationID.x]]].pos + alpha / (float(size) - 1.0f) * pos;
new_vertices[gl_GlobalInvocationID.x].norm = normalize((1.0f - alpha) * vertices[indices[offsets[gl_GlobalInvocationID.x]]].norm + alpha / (float(size) - 1.0f) * norm);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment