diff options
| author | Vaxry <vaxry@vaxry.net> | 2023-10-19 14:04:50 +0100 |
|---|---|---|
| committer | Vaxry <vaxry@vaxry.net> | 2023-10-19 14:05:02 +0100 |
| commit | 6e15590e98ca643d06eacc84adf161bcef705c0b (patch) | |
| tree | 38fa72ef0e5b6425cb4a1eb37af3a7555ac34c4e /src/render/shaders | |
| parent | d70cc88dab11bc6d1095523a0ce655dff40b27a2 (diff) | |
shaders: support changing the outer radius of borders independently
Diffstat (limited to 'src/render/shaders')
| -rw-r--r-- | src/render/shaders/Border.hpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/render/shaders/Border.hpp b/src/render/shaders/Border.hpp index f7b9d94d..79493da9 100644 --- a/src/render/shaders/Border.hpp +++ b/src/render/shaders/Border.hpp @@ -12,6 +12,7 @@ uniform vec2 topLeft; uniform vec2 fullSize; uniform vec2 fullSizeUntransformed; uniform float radius; +uniform float radiusOuter; uniform float thick; uniform vec4 gradient[10]; @@ -51,6 +52,7 @@ vec4 getColorForCoord(vec2 normalizedCoord) { void main() { highp vec2 pixCoord = vec2(gl_FragCoord); + highp vec2 pixCoordOuter = pixCoord; highp vec2 originalPixCoord = v_texcoord; originalPixCoord *= fullSizeUntransformed; float additionalAlpha = 1.0; @@ -61,25 +63,33 @@ void main() { pixCoord -= topLeft + fullSize * 0.5; pixCoord *= vec2(lessThan(pixCoord, vec2(0.0))) * -2.0 + 1.0; + pixCoordOuter = pixCoord; pixCoord -= fullSize * 0.5 - radius; - pixCoord += vec2(1.0, 1.0) / fullSize; // center the pix dont make it top-left + pixCoordOuter -= fullSize * 0.5 - radiusOuter; - if (min(pixCoord.x, pixCoord.y) > 0.0 && radius > 0.0) { + // center the pixes dont make it top-left + pixCoord += vec2(1.0, 1.0) / fullSize; + pixCoordOuter += vec2(1.0, 1.0) / fullSize; + if (min(pixCoord.x, pixCoord.y) > 0.0 && radius > 0.0) { float dist = length(pixCoord); + float distOuter = length(pixCoordOuter); float h = (thick / 2.0); if (dist < radius - h) { // lower float normalized = smoothstep(0.0, 1.0, dist - radius + thick + 0.5); additionalAlpha *= normalized; - } else { + done = true; + } else if (min(pixCoordOuter.x, pixCoordOuter.y) > 0.0) { // higher - float normalized = 1.0 - smoothstep(0.0, 1.0, dist - radius + 0.5); + float normalized = 1.0 - smoothstep(0.0, 1.0, distOuter - radiusOuter + 0.5); additionalAlpha *= normalized; + done = true; + } else if (distOuter < radiusOuter - h) { + additionalAlpha = 1.0; + done = true; } - - done = true; } // now check for other shit |
