aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/skyhanni/shaders
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2023-10-14 10:05:48 +0100
committerGitHub <noreply@github.com>2023-10-14 11:05:48 +0200
commit16ef943b3c2ce8db2331332261143a12bdba61cf (patch)
tree52c764205ef2464c62b05e3585390b61c69bcdda /src/main/resources/assets/skyhanni/shaders
parentbfae99cb54988568b2752c7d6a8d3d5babed1bbc (diff)
downloadskyhanni-16ef943b3c2ce8db2331332261143a12bdba61cf.tar.gz
skyhanni-16ef943b3c2ce8db2331332261143a12bdba61cf.tar.bz2
skyhanni-16ef943b3c2ce8db2331332261143a12bdba61cf.zip
Feature: SBA Chroma but in SH (#487)
Porting SBA's chroma into SkyHanni with many more options and chroma everything. #487
Diffstat (limited to 'src/main/resources/assets/skyhanni/shaders')
-rw-r--r--src/main/resources/assets/skyhanni/shaders/chroma.fsh43
-rw-r--r--src/main/resources/assets/skyhanni/shaders/chroma.vsh15
2 files changed, 58 insertions, 0 deletions
diff --git a/src/main/resources/assets/skyhanni/shaders/chroma.fsh b/src/main/resources/assets/skyhanni/shaders/chroma.fsh
new file mode 100644
index 000000000..7b48a62f9
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/chroma.fsh
@@ -0,0 +1,43 @@
+// Chroma Fragment Shader
+// Modified from SkyblockAddons
+// Credit: https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/resources/assets/skyblockaddons/shaders/program/chroma_screen_textured.fsh
+
+#version 120
+
+uniform float chromaSize;
+uniform float timeOffset;
+uniform float saturation;
+uniform bool forwardDirection;
+
+uniform sampler2D outTexture;
+
+varying vec2 outTextureCoords;
+varying vec4 outColor;
+
+float rgb2b(vec3 rgb) {
+ return max(max(rgb.r, rgb.g), rgb.b);
+}
+
+vec3 hsb2rgb_smooth(vec3 c) {
+ vec3 rgb = clamp(abs(mod(c.x * 6.0 + vec3(0.0, 4.0, 2.0), 6.0) - 3.0) - 1.0, 0.0, 1.0);
+ rgb = rgb * rgb * (3.0 - 2.0 * rgb); // Cubic smoothing
+ return c.z * mix(vec3(1.0), rgb, c.y);
+}
+
+void main() {
+ vec4 originalColor = texture2D(outTexture, outTextureCoords) * outColor;
+
+ // Determine the direction chroma moves
+ float fragCoord;
+ if (forwardDirection) {
+ fragCoord = gl_FragCoord.x - gl_FragCoord.y;
+ } else {
+ fragCoord = gl_FragCoord.x + gl_FragCoord.y;
+ }
+
+ // The hue takes in account the position, chroma settings, and time
+ float hue = mod(((fragCoord) / chromaSize) - timeOffset, 1.0);
+
+ // Set the color to use the new hue & original saturation/value/alpha values
+ gl_FragColor = vec4(hsb2rgb_smooth(vec3(hue, saturation, rgb2b(originalColor.rgb))), originalColor.a);
+} \ No newline at end of file
diff --git a/src/main/resources/assets/skyhanni/shaders/chroma.vsh b/src/main/resources/assets/skyhanni/shaders/chroma.vsh
new file mode 100644
index 000000000..5f5030d07
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/chroma.vsh
@@ -0,0 +1,15 @@
+// Chroma Vertex Shader
+// Credit: https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/resources/assets/skyblockaddons/shaders/program/chroma_screen_textured.vsh
+
+#version 120
+
+varying vec2 outTextureCoords;
+varying vec4 outColor;
+
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+
+ // Pass the color & texture coords to the fragment shader
+ outColor = gl_Color;
+ outTextureCoords = gl_MultiTexCoord0.st;
+}