aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets
diff options
context:
space:
mode:
authorBrady <thatgravyboat@gmail.com>2024-07-28 08:04:52 -0230
committerGitHub <noreply@github.com>2024-07-28 12:34:52 +0200
commita41214df4d112444eca29fe60684cc051382a33c (patch)
tree2de4a300be9592090aacf3615fd9f5881a77e9f8 /src/main/resources/assets
parent32d3a6ae845475284cc5f72dac5649d732c223b5 (diff)
downloadskyhanni-a41214df4d112444eca29fe60684cc051382a33c.tar.gz
skyhanni-a41214df4d112444eca29fe60684cc051382a33c.tar.bz2
skyhanni-a41214df4d112444eca29fe60684cc051382a33c.zip
Improvement: Apply border radius to scoreboard texture (#2228)
Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/resources/assets')
-rw-r--r--src/main/resources/assets/skyhanni/shaders/rounded_texture.fsh37
-rw-r--r--src/main/resources/assets/skyhanni/shaders/rounded_texture.vsh10
2 files changed, 47 insertions, 0 deletions
diff --git a/src/main/resources/assets/skyhanni/shaders/rounded_texture.fsh b/src/main/resources/assets/skyhanni/shaders/rounded_texture.fsh
new file mode 100644
index 000000000..a38ebc4ea
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/rounded_texture.fsh
@@ -0,0 +1,37 @@
+#version 120
+
+uniform float scaleFactor;
+uniform float radius;
+uniform float smoothness;
+uniform vec2 halfSize;
+uniform vec2 centerPos;
+
+uniform sampler2D outTexture;
+
+varying vec2 outTextureCoords;
+varying vec4 outColor;
+
+// From https://www.shadertoy.com/view/WtdSDs
+float roundedRectSDF(vec2 center, vec2 halfSize, float radius) {
+ return length(max(abs(center) - halfSize + radius, 0.0)) - radius;
+}
+
+void main() {
+ float xScale = gl_ModelViewMatrix[0][0];
+ float yScale = gl_ModelViewMatrix[1][1];
+ float xTranslation = gl_ModelViewMatrix[3][0];
+ float yTranslation = gl_ModelViewMatrix[3][1];
+
+ vec2 newHalfSize = vec2(halfSize.x * xScale, halfSize.y * yScale);
+
+ float newCenterPosY = centerPos.y;
+ if (yScale > 1.0) {
+ newCenterPosY = centerPos.y - (halfSize.y * (yScale - 1));
+ }
+
+ vec2 newCenterPos = vec2((centerPos.x * xScale) + (xTranslation * scaleFactor), newCenterPosY - (yTranslation * scaleFactor));
+
+ float distance = roundedRectSDF(gl_FragCoord.xy - newCenterPos, newHalfSize, radius);
+ float smoothed = 1.0 - smoothstep(0.0, smoothness, distance);
+ gl_FragColor = (texture2D(outTexture, outTextureCoords) * outColor) * vec4(1.0, 1.0, 1.0, smoothed);
+}
diff --git a/src/main/resources/assets/skyhanni/shaders/rounded_texture.vsh b/src/main/resources/assets/skyhanni/shaders/rounded_texture.vsh
new file mode 100644
index 000000000..227f964a1
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/rounded_texture.vsh
@@ -0,0 +1,10 @@
+#version 120
+
+varying vec2 outTextureCoords;
+varying vec4 outColor;
+
+void main(){
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ outColor = gl_Color;
+ outTextureCoords = gl_MultiTexCoord0.st;
+}