aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/notenoughupdates/shaders/node.compute
diff options
context:
space:
mode:
authorMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-14 10:23:12 +0800
committerMoulberry <james.jenour@student.scotch.wa.edu.au>2020-07-14 10:23:12 +0800
commitf90f0b2f1f234d08742a4f0dd8afcd4b80e26d05 (patch)
treea3b7def680964e2015afb3e3188b955e64679f9a /src/main/resources/assets/notenoughupdates/shaders/node.compute
parent2254c0fac78dbca807a93648c60c93281b8fb686 (diff)
downloadNotEnoughUpdates-f90f0b2f1f234d08742a4f0dd8afcd4b80e26d05.tar.gz
NotEnoughUpdates-f90f0b2f1f234d08742a4f0dd8afcd4b80e26d05.tar.bz2
NotEnoughUpdates-f90f0b2f1f234d08742a4f0dd8afcd4b80e26d05.zip
something something capes
Diffstat (limited to 'src/main/resources/assets/notenoughupdates/shaders/node.compute')
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/node.compute39
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