#version 440 // Liquid glass for the lock screen, where compositor glass (HyprGlass) does not // reach session-lock surfaces. A shape mask and its blurred copy (a height // field) give an edge profile; the frosted backdrop is refracted towards the // rim with RGB dispersion, plus a fresnel rim and a light-facing highlight. // Rebuild glass.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; vec4 sourceRect; // backdrop UV rect covered by this item vec2 pixelStep; // 1 / item size in pixels float refraction; // edge displacement in pixels float dispersion; // RGB split, fraction of the displacement float fresnel; float specular; float brightness; float saturation; vec4 tint; // rgb tint, a = amount }; layout(binding = 1) uniform sampler2D backdropMap; layout(binding = 2) uniform sampler2D maskMap; layout(binding = 3) uniform sampler2D heightMap; vec3 backdropAt(vec2 uv) { return texture(backdropMap, sourceRect.xy + clamp(uv, 0.0, 1.0) * sourceRect.zw).rgb; } void main() { vec2 uv = qt_TexCoord0; float shape = texture(maskMap, uv).a; if (shape < 0.002) { fragColor = vec4(0.0); return; } float h = texture(heightMap, uv).a; vec2 e = pixelStep * 2.0; vec2 slope = vec2(texture(heightMap, uv + vec2(e.x, 0.0)).a - texture(heightMap, uv - vec2(e.x, 0.0)).a, texture(heightMap, uv + vec2(0.0, e.y)).a - texture(heightMap, uv - vec2(0.0, e.y)).a); float rim = 1.0 - smoothstep(0.0, 1.0, h); vec2 inward = length(slope) > 1e-5 ? normalize(slope) : vec2(0.0); // Pull the backdrop in from the rim, as a convex lens would. vec2 offset = inward * refraction * rim * rim * pixelStep; vec3 color = vec3(backdropAt(uv + offset * (1.0 + dispersion)).r, backdropAt(uv + offset).g, backdropAt(uv + offset * (1.0 - dispersion)).b); float luma = dot(color, vec3(0.2126, 0.7152, 0.0722)); color = mix(vec3(luma), color, saturation) * brightness; color = mix(color, tint.rgb, tint.a); color += vec3(fresnel) * pow(rim, 3.0) * 0.55; // Light from the top left catches the rim facing it. float facing = max(0.0, dot(inward, normalize(vec2(1.0, 1.0)))); color += vec3(specular) * pow(rim, 4.0) * facing * 0.9; fragColor = vec4(clamp(color, 0.0, 1.0), 1.0) * shape * qt_Opacity; }