aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/notenoughupdates/shaders
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources/assets/notenoughupdates/shaders')
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/cape.frag16
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/cape.vert12
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag31
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/fade_cape.vert12
-rw-r--r--src/main/resources/assets/notenoughupdates/shaders/node.compute39
5 files changed, 110 insertions, 0 deletions
diff --git a/src/main/resources/assets/notenoughupdates/shaders/cape.frag b/src/main/resources/assets/notenoughupdates/shaders/cape.frag
new file mode 100644
index 00000000..cbe00c70
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/cape.frag
@@ -0,0 +1,16 @@
+#version 120
+
+varying vec4 passColour;
+varying vec3 passNormal;
+uniform sampler2D textureIn;
+
+void main() {
+ vec4 texture = texture2D(textureIn, gl_TexCoord[0].st);
+ gl_FragColor = texture * passColour;
+
+ vec3 fakeSunNormal = normalize(vec3(0.2f,1f,-0.2f));
+ vec3 normNormal = normalize(passNormal);
+ float shading = max(0.6f, dot(fakeSunNormal, normNormal));
+
+ gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a);//gl_FragColor.rgb*shading
+} \ No newline at end of file
diff --git a/src/main/resources/assets/notenoughupdates/shaders/cape.vert b/src/main/resources/assets/notenoughupdates/shaders/cape.vert
new file mode 100644
index 00000000..2b5c48f8
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/cape.vert
@@ -0,0 +1,12 @@
+#version 120
+
+varying vec4 passColour;
+varying vec3 passNormal;
+
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ passColour = gl_Color;
+ passNormal = normalize(gl_Normal);
+} \ No newline at end of file
diff --git a/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag b/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag
new file mode 100644
index 00000000..76738c31
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/fade_cape.frag
@@ -0,0 +1,31 @@
+#version 120
+
+varying vec4 passColour;
+varying vec3 passNormal;
+uniform sampler2D textureIn;
+
+uniform int millis;
+
+//Algorithm by hughsk
+vec3 hsv2rgb(vec3 c) {
+ vec4 K = vec4(1.0, 2.0 / 3.0, 1.0 / 3.0, 3.0);
+ vec3 p = abs(fract(c.xxx + K.xyz) * 6.0 - K.www);
+ return c.z * mix(K.xxx, clamp(p - K.xxx, 0.0, 1.0), c.y);
+}
+
+void main() {
+ vec4 texture = texture2D(textureIn, gl_TexCoord[0].st);
+
+ float hue = mod(millis/10000f+gl_TexCoord[0].t, 1f);
+ float sat = 0.5f;
+ float val = 0.5f;
+ vec3 fade = hsv2rgb(vec3(hue, sat, val));
+
+ gl_FragColor = vec4(texture.rgb*texture.a + fade*(1-texture.a), 1f) * passColour;
+
+ vec3 fakeSunNormal = normalize(vec3(0.2f,1f,-0.2f));
+ vec3 normNormal = normalize(passNormal);
+ float shading = max(0.6f, dot(fakeSunNormal, normNormal));
+
+ gl_FragColor = vec4(gl_FragColor.rgb*shading, gl_FragColor.a);
+} \ No newline at end of file
diff --git a/src/main/resources/assets/notenoughupdates/shaders/fade_cape.vert b/src/main/resources/assets/notenoughupdates/shaders/fade_cape.vert
new file mode 100644
index 00000000..2b5c48f8
--- /dev/null
+++ b/src/main/resources/assets/notenoughupdates/shaders/fade_cape.vert
@@ -0,0 +1,12 @@
+#version 120
+
+varying vec4 passColour;
+varying vec3 passNormal;
+
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ gl_TexCoord[0] = gl_MultiTexCoord0;
+
+ passColour = gl_Color;
+ passNormal = normalize(gl_Normal);
+} \ No newline at end of file
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