aboutsummaryrefslogtreecommitdiff
path: root/src/main/resources
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/resources')
-rw-r--r--src/main/resources/assets/skyhanni/shaders/rounded_rect.fsh34
-rw-r--r--src/main/resources/assets/skyhanni/shaders/rounded_rect.vsh8
2 files changed, 42 insertions, 0 deletions
diff --git a/src/main/resources/assets/skyhanni/shaders/rounded_rect.fsh b/src/main/resources/assets/skyhanni/shaders/rounded_rect.fsh
new file mode 100644
index 000000000..9f3c31786
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/rounded_rect.fsh
@@ -0,0 +1,34 @@
+#version 130
+
+uniform float scaleFactor;
+uniform float radius;
+uniform float smoothness;
+uniform vec2 halfSize;
+uniform vec2 centerPos;
+
+in 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, radius);
+ float smoothed = 1.0 - smoothstep(0.0, smoothness, distance);
+ gl_FragColor = color * vec4(1.0, 1.0, 1.0, smoothed);
+} \ No newline at end of file
diff --git a/src/main/resources/assets/skyhanni/shaders/rounded_rect.vsh b/src/main/resources/assets/skyhanni/shaders/rounded_rect.vsh
new file mode 100644
index 000000000..beadbf5fb
--- /dev/null
+++ b/src/main/resources/assets/skyhanni/shaders/rounded_rect.vsh
@@ -0,0 +1,8 @@
+#version 130
+
+out vec4 color;
+
+void main() {
+ gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex;
+ color = gl_Color;
+} \ No newline at end of file