aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl
diff options
context:
space:
mode:
authorMary <33456283+FourIsTheNumber@users.noreply.github.com>2024-09-07 09:16:14 -0400
committerGitHub <noreply@github.com>2024-09-07 13:16:14 +0000
commitf2c0a4fc6b65749871b60580a6f65374f589b994 (patch)
tree47d7ffeb0f74eb49fb707b6dfd001c6052c4ebeb /src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl
parent67607edb5343c892e46767db782da3b7da0f4c5a (diff)
downloadGT5-Unofficial-f2c0a4fc6b65749871b60580a6f65374f589b994.tar.gz
GT5-Unofficial-f2c0a4fc6b65749871b60580a6f65374f589b994.tar.bz2
GT5-Unofficial-f2c0a4fc6b65749871b60580a6f65374f589b994.zip
Finishing touches on black hole compressor (#3060)
Co-authored-by: Martin Robertz <dream-master@gmx.net> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: BucketBrigade <138534411+CookieBrigade@users.noreply.github.com>
Diffstat (limited to 'src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl')
-rw-r--r--src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl81
1 files changed, 81 insertions, 0 deletions
diff --git a/src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl b/src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl
new file mode 100644
index 0000000000..57cea0b81c
--- /dev/null
+++ b/src/main/resources/assets/gregtech/shaders/blackhole.vert.glsl
@@ -0,0 +1,81 @@
+#version 120
+
+uniform float u_Time;
+uniform float u_Stability;
+uniform float u_Scale;
+uniform vec3 u_CameraPosition;
+
+varying vec2 v_TexCoord;
+
+const float PI = 3.14159265358979323846;
+
+const float HORIZON_EDGE = 2.6;
+
+mat4 rotateMatrix(float angle, vec3 axis){
+ float x = axis.x;
+ float y = axis.y;
+ float z = axis.z;
+
+ float c = cos(angle);
+ float s = sin(angle);
+ float t = 1.0 - c;
+
+ return mat4(
+ c+x*x*t, t*x*y - s*z, t*x*z + s*y, 0.0,
+ t*x*y + s*z, t*y*y + c, t*y*z - s*x, 0.0,
+ t*x*z - s*y, t*y*z + s*x, t*z*z + c, 0.0,
+ 0.0, 0.0, 0.0, 1.0
+ );
+}
+
+
+
+
+
+void main() {
+
+ v_TexCoord = gl_MultiTexCoord0.xy;
+
+ //Extremely fragile system to deteriminte if isolate parts of the blackhole
+ //Would break with any uv remaping or atlas stiching
+ bool isDisk = (abs(v_TexCoord.y-.5f)>.245);
+ bool isBack = (abs(v_TexCoord.x-.5f)>.245) && isDisk;
+ bool isFront = (abs(v_TexCoord.x-.5f)<.255) && isDisk;
+ bool isBot = (v_TexCoord.y < .5) && isBack;
+
+ float yAngle = atan(u_CameraPosition.z,u_CameraPosition.x) - PI/2;
+ float c = cos(yAngle);
+ float s = sin(yAngle);
+ mat4 yRotate = mat4(
+ vec4(c, 0.0, s, 0.0), // First column
+ vec4(0.0, 1.0, 0.0, 0.0), // Second column
+ vec4(-s, 0.0, c, 0.0), // Third column
+ vec4(0.0, 0.0, 0.0, 1.0) // Fourth column
+ );
+
+
+ float base = length(gl_Vertex.xyz);
+ float stab = (base>HORIZON_EDGE)?u_Stability:1;
+
+ float scale = ((base-HORIZON_EDGE)*stab+HORIZON_EDGE)/base;
+ scale = max(scale, .1);
+ scale*=u_Scale;
+
+
+ vec4 rotated = yRotate * vec4((gl_Vertex.xyz*scale),1);
+
+ vec3 cameraDirection = normalize(u_CameraPosition);
+ cameraDirection = !isBot?cameraDirection:-cameraDirection;
+ vec3 rotateAxis = cross(cameraDirection,vec3(0,1,0));
+ float angle = acos(dot(cameraDirection,vec3(0,1,0)));
+ if (isFront) angle = 0;
+
+ float instabilityRotation =(u_Stability<=0)?u_Time/10:0;
+
+ mat4 rotate = rotateMatrix(angle,normalize(rotateAxis));
+
+
+ mat4 rotateB = rotateMatrix(instabilityRotation,normalize(u_CameraPosition));
+
+ gl_Position = gl_ModelViewProjectionMatrix * (rotateB* (rotate * (rotated)));
+}