Commit af72c003 by Philipp Adolf

Implement vertex shader

parent 9c5ff7de
#version 430 core #version 430 core
#define M_PI 3.14159265358979323846
layout (local_size_x = 1) in; layout (local_size_x = 1) in;
struct Vertex { struct Vertex {
...@@ -25,4 +27,19 @@ layout(std430, binding=3) writeonly buffer Output { ...@@ -25,4 +27,19 @@ layout(std430, binding=3) writeonly buffer Output {
}; };
void main(){ 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?
float t = 3.0f/8.0f + 2.0f/8.0f * cos(2.0f * M_PI / (float(size) - 1.0f));
float alpha = 5.0f/8.0f - t * t;
vec3 pos = vec3(0.0f, 0.0f, 0.0f);
for (unsigned int i = 1; i < size; i++) {
pos += vertices[indices[offsets[gl_GlobalInvocationID.x] + i]].pos;
}
new_vertices[gl_GlobalInvocationID.x].pos = (1.0f - alpha) * vertices[indices[offsets[gl_GlobalInvocationID.x]]].pos + alpha / (float(size) - 1) * pos;
} }
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