aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources/assets/skyhanni/shaders
diff options
context:
space:
mode:
authorVixid <52578495+VixidDev@users.noreply.github.com>2024-04-27 12:07:55 +0100
committerGitHub <noreply@github.com>2024-04-27 13:07:55 +0200
commita15ef68de8e33df296c565d12994df2ee965626e (patch)
tree4651c999d759859988c0f169eeaf3cf4bb9bd8f8 /src/main/resources/assets/skyhanni/shaders
parent328750a979e162ba92ec8957e81bf89989d61f63 (diff)
downloadskyhanni-a15ef68de8e33df296c565d12994df2ee965626e.tar.gz
skyhanni-a15ef68de8e33df296c565d12994df2ee965626e.tar.bz2
skyhanni-a15ef68de8e33df296c565d12994df2ee965626e.zip
Improvement: Added Outline to Custom Scoreboard (#1461)
Co-authored-by: J10a1n15 <45315647+j10a1n15@users.noreply.github.com> Co-authored-by: hannibal2 <24389977+hannibal00212@users.noreply.github.com>
Diffstat (limited to 'src/main/resources/assets/skyhanni/shaders')
-rw-r--r--src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.fsh40
-rw-r--r--src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.vsh8
2 files changed, 48 insertions, 0 deletions
diff --git a/src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.fsh b/src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.fsh
new file mode 100644
index 000000000..278390056
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.fsh
@@ -0,0 +1,40 @@
+#version 120
+
+// Rect specific uniforms
+uniform float scaleFactor;
+uniform float radius;
+uniform vec2 halfSize;
+uniform vec2 centerPos;
+
+// Outline specific uniforms
+uniform float borderThickness;
+uniform float borderBlur;
+
+varying vec4 color;
+
+// 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, max(radius, borderThickness));
+
+ // In testing, keeping the upper bound at 1.0 and letting the lower be changable seemed the most sensible for nice results
+ float smoothed = 1.0 - smoothstep(borderBlur, 1.0, abs(distance / borderThickness));
+ gl_FragColor = color * vec4(1.0, 1.0, 1.0, smoothed);
+}
diff --git a/src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.vsh b/src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.vsh
new file mode 100644
index 000000000..acfb52662
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/rounded_rect_outline.vsh
@@ -0,0 +1,8 @@
+#version 120
+
+varying vec4 color;
+
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ color = gl_Color;
+}