diff options
Diffstat (limited to 'src/main/resources/assets/notenoughupdates/shaders/node.compute')
-rw-r--r-- | src/main/resources/assets/notenoughupdates/shaders/node.compute | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/main/resources/assets/notenoughupdates/shaders/node.compute b/src/main/resources/assets/notenoughupdates/shaders/node.compute new file mode 100644 index 00000000..df60dfdc --- /dev/null +++ b/src/main/resources/assets/notenoughupdates/shaders/node.compute @@ -0,0 +1,39 @@ +#version 430 compatibility +#extension GL_ARB_compute_shader : enable +#extension GL_ARB_shader_storage_buffer_object : enable + +#define HORZ_NODES 6 +#define VERT_NODES 22 + +#define INDEX gl_GlobalInvocationID.x + +#define TARGET_DIST 0.05f + +layout(local_size_x = HORZ_NODES, local_size_y = 1, local_size_z = 1) in; + +struct Node { + vec3 position; + float numInfluences; + vec2 influences[8]; +}; + +layout(std430, binding=0) buffer nodes_buffer { + Node nodes[HORZ_NODES*VERT_NODES]; +}; + + +void resolve(vec2 influence, float strength) { + vec3 dist = nodes[INDEX+int(influence.x)].position - nodes[INDEX].position; + float l = length(dist); + float factor = strength*(l - influence.y)/(2f*l); + + if(INDEX >= HORZ_NODES) nodes[INDEX].position = nodes[INDEX].position + dist * factor; +} + +void main() { + float kPrime = 1.0 - pow(1-0.9f, 1.0/30f); //K = 0.9f + kPrime = 0.5f; + + int influences = int(nodes[INDEX].numInfluences); + for(int i=0; i<influences; i++) resolve(nodes[INDEX].influences[i], kPrime); +}
\ No newline at end of file |