#version 440 // Notch-mode panel opening (NotchDrop.qml): a glass bead swells out of the // island under the clicked icon on a tapered neck, flips the wallpaper behind // it like a lens, then widens into the panel and the neck lets go. // The shape is one signed distance field: an uneven capsule (the neck) melted // into a rounded box (bead, then panel). Geometry comes from QML per frame. // Output is premultiplied; HyprGlass adds its blur where alpha is above its // mask threshold, so the lens and fill sit on top of the compositor glass. // Rebuild notchdrop.frag.qsb with scripts/build-shaders after editing. layout(location = 0) in vec2 qt_TexCoord0; layout(location = 0) out vec4 fragColor; layout(std140, binding = 0) uniform buf { mat4 qt_Matrix; float qt_Opacity; vec2 size; // item size, px float topY; // drawer-local y of the item's top edge vec4 stem; // neck: top x, top y, top radius, bottom radius float stemH; // neck length vec4 box; // bead/panel: centre x, y, half width, half height float boxR; float melt; // smooth-union width between neck and bead vec4 lens; // centre x, y, radius, strength vec4 fill; // premultiplied vec4 edge; // premultiplied hairline vec4 cover; // screen px -> wallpaper uv: scale xy, offset zw vec2 screenOrigin; // screen position of drawer-local (0, 0) float hasWall; }; layout(binding = 1) uniform sampler2D wall; float sdBox(vec2 p, vec2 c, vec2 h, float r) { r = min(r, min(h.x, h.y)); vec2 q = abs(p - c) - h + r; return length(max(q, 0.0)) + min(max(q.x, q.y), 0.0) - r; } // Vertical capsule with different end radii, axis pointing down (+y). float sdNeck(vec2 p, float r1, float r2, float h) { h = max(h, abs(r1 - r2) + 0.5); p.x = abs(p.x); float b = (r1 - r2) / h; float a = sqrt(max(1.0 - b * b, 0.0)); float k = dot(p, vec2(-b, a)); if (k < 0.0) return length(p) - r1; if (k > a * h) return length(p - vec2(0.0, h)) - r2; return dot(p, vec2(a, b)) - r1; } float smin(float a, float b, float k) { k = max(k, 0.001); float h = max(k - abs(a - b), 0.0) / k; return min(a, b) - h * h * k * 0.25; } float scene(vec2 p) { float n = stem.z + stem.w > 0.05 ? sdNeck(p - stem.xy, stem.z, stem.w, stemH) : 1e5; return smin(n, sdBox(p, box.xy, box.zw, boxR), melt); } vec3 wallAt(vec2 p) { return texture(wall, (p + screenOrigin) * cover.xy + cover.zw).rgb; } void main() { vec2 p = qt_TexCoord0 * size + vec2(0.0, topY); float d = scene(p); if (d > 1.5) { fragColor = vec4(0.0); return; } vec2 e = vec2(1.0, 0.0); vec2 g = vec2(scene(p + e.xy) - scene(p - e.xy), scene(p + e.yx) - scene(p - e.yx)); g = length(g) > 1e-5 ? normalize(g) : vec2(0.0, 1.0); // points outwards float depth = clamp(-d / 16.0, 0.0, 1.0); float rim = pow(1.0 - depth, 2.2); vec4 c = fill; // The hanging bead is a lens: the wallpaper behind it, upside down. float la = lens.w * hasWall * (1.0 - smoothstep(lens.z * 0.55, lens.z * 1.05, length(p - lens.xy))); if (la > 0.002) { vec2 q = lens.xy - (p - lens.xy) * 0.9 + g * rim * 10.0; vec3 w = (wallAt(q) * 2.0 + wallAt(q + vec2(1.5, 0.0)) + wallAt(q - vec2(1.5, 0.0)) + wallAt(q + vec2(0.0, 1.5)) + wallAt(q - vec2(0.0, 1.5))) / 6.0; c = mix(c, vec4(w * 0.94, 1.0), la * 0.9); } // Light from the top left, and the bright lower lip of a drop. float r6 = pow(1.0 - depth, 6.0); float hl = r6 * (0.26 * max(0.0, dot(g, normalize(vec2(-0.6, -1.0)))) + 0.42 * max(0.0, g.y) * (0.35 + 0.65 * lens.w)); c = clamp(c + vec4(hl, hl, hl, hl * 0.6), 0.0, 1.0); // Hairline, as the other drawers have. float line = smoothstep(1.2, 0.0, abs(d + 0.5)); c = mix(c, edge + c * (1.0 - edge.a), line); fragColor = c * clamp(0.5 - d, 0.0, 1.0) * qt_Opacity; }